Ticket #14924: with_tests_2.patch

File with_tests_2.patch, 5.3 KB (added by Klaas van Schelven, 13 years ago)

Patch file syntax correct

  • django/utils/translation/trans_real.py

    # 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  
    7676        self.__language = '??'
    7777
    7878    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
    8082
    8183    def set_language(self, language):
    8284        self.__language = language
     
    131133            except IOError, e:
    132134                return None
    133135
    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 
    145136        def _merge(path):
    146137            t = _translation(path)
    147138            if t is not None:
    148139                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()
    149149                    return t
    150150                else:
    151151                    res.merge(t)
    152152            return res
    153153
    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)
    157156
    158157        for appname in settings.INSTALLED_APPS:
    159158            apppath = os.path.join(get_apppath(appname), 'locale')
     
    161160            if os.path.isdir(apppath):
    162161                res = _merge(apppath)
    163162
    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)
    166168
    167169        if res is None:
    168170            if fallback is not None:
  • new file tests/regressiontests/i18n/resolution_high_priority/locale/de/LC_MESSAGES/django.po

    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
     7msgid ""
     8msgstr ""
     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
     21msgid "Date/time"
     22msgstr "Datum/Zeit (FIRST APP)"
  • new file tests/regressiontests/i18n/resolution_high_priority/models.py

    diff -r e5ddbcaf1ab1 -r c1f8daed4a18 tests/regressiontests/i18n/resolution_high_priority/models.py
    - +  
     1#
  • tests/regressiontests/i18n/tests.py

    diff -r e5ddbcaf1ab1 -r c1f8daed4a18 tests/regressiontests/i18n/tests.py
    a b  
    608608    def test_app_translation(self):
    609609        self.assertUgettext('Date/time', 'APP')
    610610
     611class 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
    611625class LocalePathsResolutionOrderI18NTests(ResolutionOrderI18NTests):
    612626
    613627    def setUp(self):
Back to Top