mirror of
https://github.com/django/django.git
synced 2025-01-10 18:36:05 +00:00
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:
parent
631d127bd2
commit
48b67fe4bb
@ -133,17 +133,23 @@ def javascript_catalog(request, domain='djangojs', packages=None):
|
|||||||
locale = to_locale(get_language())
|
locale = to_locale(get_language())
|
||||||
t = {}
|
t = {}
|
||||||
paths = []
|
paths = []
|
||||||
|
# first load all english languages files for defaults
|
||||||
for package in packages:
|
for package in packages:
|
||||||
p = __import__(package, {}, {}, [''])
|
p = __import__(package, {}, {}, [''])
|
||||||
path = os.path.join(os.path.dirname(p.__file__), 'locale')
|
path = os.path.join(os.path.dirname(p.__file__), 'locale')
|
||||||
paths.append(path)
|
paths.append(path)
|
||||||
#!!! add loading of catalogs from settings.LANGUAGE_CODE and request.LANGUAGE_CODE!
|
catalog = gettext_module.translation(domain, path, ['en'])
|
||||||
try:
|
t.update(catalog._catalog)
|
||||||
catalog = gettext_module.translation(domain, path, [default_locale])
|
# next load the settings.LANGUAGE_CODE translations if it isn't english
|
||||||
except IOError, e:
|
if default_locale != 'en':
|
||||||
catalog = None
|
for path in paths:
|
||||||
if catalog is not None:
|
try:
|
||||||
t.update(catalog._catalog)
|
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:
|
if locale != default_locale:
|
||||||
for path in paths:
|
for path in paths:
|
||||||
try:
|
try:
|
||||||
@ -154,9 +160,10 @@ def javascript_catalog(request, domain='djangojs', packages=None):
|
|||||||
t.update(catalog._catalog)
|
t.update(catalog._catalog)
|
||||||
src = [LibHead]
|
src = [LibHead]
|
||||||
plural = None
|
plural = None
|
||||||
for l in t[''].split('\n'):
|
if t.has_key(''):
|
||||||
if l.startswith('Plural-Forms:'):
|
for l in t[''].split('\n'):
|
||||||
plural = l.split(':',1)[1].strip()
|
if l.startswith('Plural-Forms:'):
|
||||||
|
plural = l.split(':',1)[1].strip()
|
||||||
if plural is not None:
|
if plural is not None:
|
||||||
# this should actually be a compiled function of a typical plural-form:
|
# this should actually be a compiled function of a typical plural-form:
|
||||||
# Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;
|
# Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;
|
||||||
|
Loading…
Reference in New Issue
Block a user