|
@@ -177,6 +177,7 @@ def javascript_catalog(request, domain='djangojs', packages=None):
|
|
|
locale = to_locale(get_language())
|
|
|
t = {}
|
|
|
paths = []
|
|
|
+ en_catalog_missing = False
|
|
|
# first load all english languages files for defaults
|
|
|
for package in packages:
|
|
|
p = importlib.import_module(package)
|
|
@@ -186,7 +187,12 @@ def javascript_catalog(request, domain='djangojs', packages=None):
|
|
|
catalog = gettext_module.translation(domain, path, ['en'])
|
|
|
t.update(catalog._catalog)
|
|
|
except IOError:
|
|
|
- # 'en' catalog was missing. This is harmless.
|
|
|
+ # 'en' catalog was missing.
|
|
|
+ if locale.startswith('en'):
|
|
|
+ # If 'en' is the selected language this would cause issues
|
|
|
+ # later on if default_locale is something other than 'en'.
|
|
|
+ en_catalog_missing = True
|
|
|
+ # Otherwise it is harmless.
|
|
|
pass
|
|
|
# next load the settings.LANGUAGE_CODE translations if it isn't english
|
|
|
if default_locale != 'en':
|
|
@@ -199,13 +205,21 @@ def javascript_catalog(request, domain='djangojs', packages=None):
|
|
|
t.update(catalog._catalog)
|
|
|
# last load the currently selected language, if it isn't identical to the default.
|
|
|
if locale != default_locale:
|
|
|
- for path in paths:
|
|
|
- try:
|
|
|
- catalog = gettext_module.translation(domain, path, [locale])
|
|
|
- except IOError:
|
|
|
- catalog = None
|
|
|
- if catalog is not None:
|
|
|
- t.update(catalog._catalog)
|
|
|
+ # If the flag en_catalog_missing has been set, the currently
|
|
|
+ # selected language is English but it doesn't have a translation
|
|
|
+ # catalog (presumably due to being the language translated from).
|
|
|
+ # If that is the case, a wrong language catalog might have been
|
|
|
+ # loaded in the previous step. It needs to be discarded.
|
|
|
+ if en_catalog_missing:
|
|
|
+ t = {}
|
|
|
+ else:
|
|
|
+ for path in paths:
|
|
|
+ try:
|
|
|
+ catalog = gettext_module.translation(domain, path, [locale])
|
|
|
+ except IOError:
|
|
|
+ catalog = None
|
|
|
+ if catalog is not None:
|
|
|
+ t.update(catalog._catalog)
|
|
|
src = [LibHead]
|
|
|
plural = None
|
|
|
if '' in t:
|