# HG changeset patch
# User Klaas van Schelven <klaas@vanschelven.com>
# Date 1293178735 -3600
# Branch legalsense/1.2.X
# Node ID c1f8daed4a18713aa700dcf45db3b05bc1cc054d
# Parent e5ddbcaf1ab1c497ec880fa57f0998a077a71b15
Translation patch (#14924)
diff -r e5ddbcaf1ab1 -r c1f8daed4a18 django/utils/translation/trans_real.py
a
|
b
|
|
76 | 76 | self.__language = '??' |
77 | 77 | |
78 | 78 | def merge(self, other): |
79 | | self._catalog.update(other._catalog) |
| 79 | for k, v in other._catalog.items(): |
| 80 | if k not in self._catalog: |
| 81 | self._catalog[k] = v |
80 | 82 | |
81 | 83 | def set_language(self, language): |
82 | 84 | self.__language = language |
… |
… |
|
131 | 133 | except IOError, e: |
132 | 134 | return None |
133 | 135 | |
134 | | res = _translation(globalpath) |
135 | | |
136 | | # We want to ensure that, for example, "en-gb" and "en-us" don't share |
137 | | # the same translation object (thus, merging en-us with a local update |
138 | | # doesn't affect en-gb), even though they will both use the core "en" |
139 | | # translation. So we have to subvert Python's internal gettext caching. |
140 | | base_lang = lambda x: x.split('-', 1)[0] |
141 | | if base_lang(lang) in [base_lang(trans) for trans in _translations]: |
142 | | res._info = res._info.copy() |
143 | | res._catalog = res._catalog.copy() |
144 | | |
145 | 136 | def _merge(path): |
146 | 137 | t = _translation(path) |
147 | 138 | if t is not None: |
148 | 139 | if res is None: |
| 140 | # We want to ensure that, for example, "en-gb" and "en-us" don't share |
| 141 | # the same translation object (thus, merging en-us with a local update |
| 142 | # doesn't affect en-gb), even though they will both use the core "en" |
| 143 | # translation. So we have to subvert Python's internal gettext caching. |
| 144 | |
| 145 | base_lang = lambda x: x.split('-', 1)[0] |
| 146 | if base_lang(lang) in [base_lang(trans) for trans in _translations]: |
| 147 | t._info = t._info.copy() |
| 148 | t._catalog = t._catalog.copy() |
149 | 149 | return t |
150 | 150 | else: |
151 | 151 | res.merge(t) |
152 | 152 | return res |
153 | 153 | |
154 | | for localepath in settings.LOCALE_PATHS: |
155 | | if os.path.isdir(localepath): |
156 | | res = _merge(localepath) |
| 154 | if projectpath and os.path.isdir(projectpath): |
| 155 | res = _merge(projectpath) |
157 | 156 | |
158 | 157 | for appname in settings.INSTALLED_APPS: |
159 | 158 | apppath = os.path.join(get_apppath(appname), 'locale') |
… |
… |
|
161 | 160 | if os.path.isdir(apppath): |
162 | 161 | res = _merge(apppath) |
163 | 162 | |
164 | | if projectpath and os.path.isdir(projectpath): |
165 | | res = _merge(projectpath) |
| 163 | for localepath in settings.LOCALE_PATHS: |
| 164 | if os.path.isdir(localepath): |
| 165 | res = _merge(localepath) |
| 166 | |
| 167 | res = _merge(globalpath) |
166 | 168 | |
167 | 169 | if res is None: |
168 | 170 | if fallback is not None: |
diff -r e5ddbcaf1ab1 -r c1f8daed4a18 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 e5ddbcaf1ab1 -r c1f8daed4a18 tests/regressiontests/i18n/resolution_high_priority/models.py
diff -r e5ddbcaf1ab1 -r c1f8daed4a18 tests/regressiontests/i18n/tests.py
a
|
b
|
|
608 | 608 | def test_app_translation(self): |
609 | 609 | self.assertUgettext('Date/time', 'APP') |
610 | 610 | |
| 611 | class AppResolutionOrderI18NTests(ResolutionOrderI18NTests): |
| 612 | |
| 613 | def setUp(self): |
| 614 | self.old_installed_apps = settings.INSTALLED_APPS |
| 615 | settings.INSTALLED_APPS = list(settings.INSTALLED_APPS) + ['regressiontests.i18n.resolution_high_priority', 'regressiontests.i18n.resolution'] |
| 616 | super(AppResolutionOrderI18NTests, self).setUp() |
| 617 | |
| 618 | def tearDown(self): |
| 619 | settings.INSTALLED_APPS = self.old_installed_apps |
| 620 | super(AppResolutionOrderI18NTests, self).tearDown() |
| 621 | |
| 622 | def test_app_translation(self): |
| 623 | self.assertUgettext('Date/time', 'FIRST APP') |
| 624 | |
611 | 625 | class LocalePathsResolutionOrderI18NTests(ResolutionOrderI18NTests): |
612 | 626 | |
613 | 627 | def setUp(self): |