mirror of
https://github.com/django/django.git
synced 2025-07-04 09:49:12 +00:00
i18n: fixed translation resolving - now project translations are pulled in allways (if they exist)
git-svn-id: http://code.djangoproject.com/svn/django/branches/i18n@837 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
50f348a92f
commit
6f88c4f9ec
@ -119,21 +119,23 @@ def translation(appname, language):
|
|||||||
except IOError: t = gettext_module.NullTranslations()
|
except IOError: t = gettext_module.NullTranslations()
|
||||||
_translations[(appname, language)] = t
|
_translations[(appname, language)] = t
|
||||||
|
|
||||||
|
parts = appname.split('.')
|
||||||
|
project = __import__(parts[0], {}, {}, [])
|
||||||
|
|
||||||
|
projectpath = os.path.join(os.path.dirname(project.__file__), 'locale')
|
||||||
|
|
||||||
|
try:
|
||||||
|
t = gettext_module.translation('django', projectpath, [language, settings.LANGUAGE_CODE], klass)
|
||||||
|
t.set_app_and_language(appname, language)
|
||||||
|
except IOError: t = None
|
||||||
|
if t is not None:
|
||||||
|
t.add_fallback(_translations[(appname, language)])
|
||||||
|
_translations[(appname, language)] = t
|
||||||
|
|
||||||
if appname != '*':
|
if appname != '*':
|
||||||
parts = appname.split('.')
|
|
||||||
project = __import__(parts[0], {}, {}, [])
|
|
||||||
app = __import__(appname, {}, {}, ['views'])
|
app = __import__(appname, {}, {}, ['views'])
|
||||||
|
|
||||||
apppath = os.path.join(os.path.dirname(app.__file__), 'locale')
|
apppath = os.path.join(os.path.dirname(app.__file__), 'locale')
|
||||||
projectpath = os.path.join(os.path.dirname(project.__file__), 'locale')
|
|
||||||
|
|
||||||
try:
|
|
||||||
t = gettext_module.translation('django', projectpath, [language, settings.LANGUAGE_CODE], klass)
|
|
||||||
t.set_app_and_language(appname, language)
|
|
||||||
except IOError: t = None
|
|
||||||
if t is not None:
|
|
||||||
t.add_fallback(_translations[(appname, language)])
|
|
||||||
_translations[(appname, language)] = t
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
t = gettext_module.translation('django', apppath, [language, settings.LANGUAGE_CODE], klass)
|
t = gettext_module.translation('django', apppath, [language, settings.LANGUAGE_CODE], klass)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user