fix for a problem with djangojs missing for some languages. Thx Olivier

git-svn-id: http://code.djangoproject.com/svn/django/trunk@1560 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Georg Bauer 2005-12-06 20:30:56 +00:00
parent 631d127bd2
commit 48b67fe4bb
1 changed files with 17 additions and 10 deletions

View File

@ -133,17 +133,23 @@ def javascript_catalog(request, domain='djangojs', packages=None):
locale = to_locale(get_language())
t = {}
paths = []
# first load all english languages files for defaults
for package in packages:
p = __import__(package, {}, {}, [''])
path = os.path.join(os.path.dirname(p.__file__), 'locale')
paths.append(path)
#!!! add loading of catalogs from settings.LANGUAGE_CODE and request.LANGUAGE_CODE!
catalog = gettext_module.translation(domain, path, ['en'])
t.update(catalog._catalog)
# next load the settings.LANGUAGE_CODE translations if it isn't english
if default_locale != 'en':
for path in paths:
try:
catalog = gettext_module.translation(domain, path, [default_locale])
except IOError, e:
catalog = None
if catalog is not 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:
@ -154,6 +160,7 @@ def javascript_catalog(request, domain='djangojs', packages=None):
t.update(catalog._catalog)
src = [LibHead]
plural = None
if t.has_key(''):
for l in t[''].split('\n'):
if l.startswith('Plural-Forms:'):
plural = l.split(':',1)[1].strip()