diff -r 275034865933 django/utils/translation/trans_real.py
a
|
b
|
|
79 | 79 | self.__language = '??' |
80 | 80 | |
81 | 81 | def merge(self, other): |
82 | | self._catalog.update(other._catalog) |
| 82 | for k, v in other._catalog.items(): |
| 83 | if k not in self._catalog: |
| 84 | self._catalog[k] = v |
83 | 85 | |
84 | 86 | def set_language(self, language): |
85 | 87 | self.__language = language |
… |
… |
|
138 | 140 | except IOError, e: |
139 | 141 | return None |
140 | 142 | |
141 | | res = _translation(globalpath) |
142 | | |
143 | | # We want to ensure that, for example, "en-gb" and "en-us" don't share |
144 | | # the same translation object (thus, merging en-us with a local update |
145 | | # doesn't affect en-gb), even though they will both use the core "en" |
146 | | # translation. So we have to subvert Python's internal gettext caching. |
147 | | base_lang = lambda x: x.split('-', 1)[0] |
148 | | if base_lang(lang) in [base_lang(trans) for trans in _translations]: |
149 | | res._info = res._info.copy() |
150 | | res._catalog = res._catalog.copy() |
151 | | |
152 | 143 | def _merge(path): |
153 | 144 | t = _translation(path) |
154 | 145 | if t is not None: |
155 | 146 | if res is None: |
| 147 | # We want to ensure that, for example, "en-gb" and "en-us" don't share |
| 148 | # the same translation object (thus, merging en-us with a local update |
| 149 | # doesn't affect en-gb), even though they will both use the core "en" |
| 150 | # translation. So we have to subvert Python's internal gettext caching. |
| 151 | |
| 152 | base_lang = lambda x: x.split('-', 1)[0] |
| 153 | if base_lang(lang) in [base_lang(trans) for trans in _translations]: |
| 154 | t._info = t._info.copy() |
| 155 | t._catalog = t._catalog.copy() |
156 | 156 | return t |
157 | 157 | else: |
158 | 158 | res.merge(t) |
159 | 159 | return res |
160 | 160 | |
161 | | for localepath in settings.LOCALE_PATHS: |
162 | | if os.path.isdir(localepath): |
163 | | res = _merge(localepath) |
| 161 | if projectpath and os.path.isdir(projectpath): |
| 162 | res = _merge(projectpath) |
164 | 163 | |
165 | 164 | for appname in settings.INSTALLED_APPS: |
166 | 165 | app = import_module(appname) |
… |
… |
|
169 | 168 | if os.path.isdir(apppath): |
170 | 169 | res = _merge(apppath) |
171 | 170 | |
172 | | if projectpath and os.path.isdir(projectpath): |
173 | | res = _merge(projectpath) |
| 171 | for localepath in settings.LOCALE_PATHS: |
| 172 | if os.path.isdir(localepath): |
| 173 | res = _merge(localepath) |
| 174 | |
| 175 | res = _merge(globalpath) |
174 | 176 | |
175 | 177 | if res is None: |
176 | 178 | if fallback is not None: |
diff -r 275034865933 tests/regressiontests/i18n/resolution_high_priority/locale/de/LC_MESSAGES/django.mo
Binary file tests/regressiontests/i18n/resolution_high_priority/locale/de/LC_MESSAGES/django.mo has changed
diff -r 275034865933 tests/regressiontests/i18n/resolution_high_priority/locale/de/LC_MESSAGES/django.po
-
|
+
|
|
| 1 | # SOME DESCRIPTIVE TITLE. |
| 2 | # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER |
| 3 | # This file is distributed under the same license as the PACKAGE package. |
| 4 | # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. |
| 5 | # |
| 6 | #, fuzzy |
| 7 | msgid "" |
| 8 | msgstr "" |
| 9 | "Project-Id-Version: PACKAGE VERSION\n" |
| 10 | "Report-Msgid-Bugs-To: \n" |
| 11 | "POT-Creation-Date: 2010-02-14 17:33+0100\n" |
| 12 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" |
| 13 | "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" |
| 14 | "Language-Team: LANGUAGE <LL@li.org>\n" |
| 15 | "MIME-Version: 1.0\n" |
| 16 | "Content-Type: text/plain; charset=UTF-8\n" |
| 17 | "Content-Transfer-Encoding: 8bit\n" |
| 18 | "Plural-Forms: nplurals=2; plural=(n != 1)\n" |
| 19 | |
| 20 | #: models.py:3 |
| 21 | msgid "Date/time" |
| 22 | msgstr "Datum/Zeit (FIRST APP)" |
diff -r 275034865933 tests/regressiontests/i18n/resolution_high_priority/models.py
-
|
+
|
|
| 1 | # |
| 2 | No newline at end of file |
diff -r 275034865933 tests/regressiontests/i18n/tests.py
a
|
b
|
|
654 | 654 | def test_app_translation(self): |
655 | 655 | self.assertUgettext('Date/time', 'APP') |
656 | 656 | |
| 657 | class AppResolutionOrderI18NTests(ResolutionOrderI18NTests): |
| 658 | |
| 659 | def setUp(self): |
| 660 | self.old_installed_apps = settings.INSTALLED_APPS |
| 661 | settings.INSTALLED_APPS = list(settings.INSTALLED_APPS) + ['regressiontests.i18n.resolution_high_priority', 'regressiontests.i18n.resolution'] |
| 662 | super(AppResolutionOrderI18NTests, self).setUp() |
| 663 | |
| 664 | def tearDown(self): |
| 665 | settings.INSTALLED_APPS = self.old_installed_apps |
| 666 | super(AppResolutionOrderI18NTests, self).tearDown() |
| 667 | |
| 668 | def test_app_translation(self): |
| 669 | self.assertUgettext('Date/time', 'FIRST APP') |
| 670 | |
657 | 671 | class LocalePathsResolutionOrderI18NTests(ResolutionOrderI18NTests): |
658 | 672 | |
659 | 673 | def setUp(self): |