Index: cms/sources.py |
=================================================================== |
--- a/cms/sources.py |
+++ b/cms/sources.py |
@@ -32,36 +32,29 @@ class Source: |
if parsed.scheme != "" or page.startswith("/") or page.startswith("."): |
# Not a page link |
return None, None |
if page == "" and url != "": |
# Page-relative link |
return None, None |
- def has_locale(locale, page): |
- try: |
- page = config.get("locale_overrides", page) |
- except ConfigParser.Error: |
- pass |
- return self.has_locale(locale, page) |
- |
config = self.read_config() |
default_locale = config.get("general", "defaultlocale") |
default_page = config.get("general", "defaultpage") |
alternative_page = "/".join([page, default_page]).lstrip("/") |
if self.has_localizable_file(default_locale, page): |
if not self.has_localizable_file(locale, page): |
locale = default_locale |
elif self.has_page(page): |
- if not has_locale(locale, page): |
+ if not self.has_locale(locale, page): |
locale = default_locale |
elif self.has_page(alternative_page): |
- if not has_locale(locale, alternative_page): |
+ if not self.has_locale(locale, alternative_page): |
locale = default_locale |
else: |
logging.warning("Link to %s cannot be resolved", page) |
parts = page.split("/") |
if parts[-1] == default_page: |
page = "/".join(parts[:-1]) |
@@ -152,18 +145,20 @@ class Source: |
for filename in self.list_files("locales"): |
if "/" in filename: |
locale, path = filename.split("/", 1) |
result.add(locale) |
return result |
def has_locale(self, locale, page): |
config = self.read_config() |
- if config.has_option("locale_overrides", page): |
+ try: |
page = config.get("locale_overrides", page) |
+ except ConfigParser.Error: |
+ pass |
return self.has_file(self.locale_filename(locale, page)) |
def read_locale(self, locale, page): |
default_locale = self.read_config().get("general", "defaultlocale") |
if locale == default_locale: |
result = {} |
else: |
result = dict(self.read_locale(default_locale, page)) |