From 6f88c4f9ecf3837d4f1bb8dcd0c437bc2bdca09d Mon Sep 17 00:00:00 2001 From: Georg Bauer Date: Tue, 11 Oct 2005 13:38:24 +0000 Subject: [PATCH] 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 --- django/utils/translation.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/django/utils/translation.py b/django/utils/translation.py index e3cb275399..1abeccf39b 100644 --- a/django/utils/translation.py +++ b/django/utils/translation.py @@ -119,21 +119,23 @@ def translation(appname, language): except IOError: t = gettext_module.NullTranslations() _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 != '*': - parts = appname.split('.') - project = __import__(parts[0], {}, {}, []) app = __import__(appname, {}, {}, ['views']) 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: t = gettext_module.translation('django', apppath, [language, settings.LANGUAGE_CODE], klass)