Ticket #18040: 18040.diff

File 18040.diff, 8.3 KB (added by Ramiro Morales, 12 years ago)
  • django/utils/translation/__init__.py

    diff --git a/django/utils/translation/__init__.py b/django/utils/translation/__init__.py
    a b  
    11"""
    22Internationalization support.
    33"""
    4 import warnings
    5 from os import path
    6 
    74from django.utils.encoding import force_unicode
    85from django.utils.functional import lazy
    9 from django.utils.importlib import import_module
    106
    117
    128__all__ = [
     
    4743        from django.conf import settings
    4844        if settings.USE_I18N:
    4945            from django.utils.translation import trans_real as trans
    50             # Make sure the project's locale dir isn't in LOCALE_PATHS
    51             if settings.SETTINGS_MODULE is not None:
    52                 parts = settings.SETTINGS_MODULE.split('.')
    53                 project = import_module(parts[0])
    54                 project_locale_path = path.normpath(
    55                     path.join(path.dirname(project.__file__), 'locale'))
    56                 normalized_locale_paths = [path.normpath(locale_path)
    57                     for locale_path in settings.LOCALE_PATHS]
    58                 if (path.isdir(project_locale_path) and
    59                         not project_locale_path in normalized_locale_paths):
    60                     warnings.warn("Translations in the project directory "
    61                                   "aren't supported anymore. Use the "
    62                                   "LOCALE_PATHS setting instead.",
    63                                   DeprecationWarning)
    6446        else:
    6547            from django.utils.translation import trans_null as trans
    6648        setattr(self, real_name, getattr(trans, real_name))
  • django/utils/translation/trans_real.py

    diff --git a/django/utils/translation/trans_real.py b/django/utils/translation/trans_real.py
    a b  
    111111
    112112    globalpath = os.path.join(os.path.dirname(sys.modules[settings.__module__].__file__), 'locale')
    113113
    114     if settings.SETTINGS_MODULE is not None:
    115         parts = settings.SETTINGS_MODULE.split('.')
    116         project = import_module(parts[0])
    117         projectpath = os.path.join(os.path.dirname(project.__file__), 'locale')
    118     else:
    119         projectpath = None
    120 
    121114    def _fetch(lang, fallback=None):
    122115
    123116        global _translations
     
    163156            if os.path.isdir(apppath):
    164157                res = _merge(apppath)
    165158
    166         localepaths = [os.path.normpath(path) for path in settings.LOCALE_PATHS]
    167         if (projectpath and os.path.isdir(projectpath) and
    168                 os.path.normpath(projectpath) not in localepaths):
    169             res = _merge(projectpath)
    170 
    171159        for localepath in reversed(settings.LOCALE_PATHS):
    172160            if os.path.isdir(localepath):
    173161                res = _merge(localepath)
  • deleted file tests/regressiontests/i18n/test_warnings.py

    diff --git a/tests/regressiontests/i18n/test_warnings.py b/tests/regressiontests/i18n/test_warnings.py
    deleted file mode 100644
    + -  
    1 import warnings
    2 from os.path import join, normpath, abspath, dirname
    3 
    4 import django
    5 from django.conf import settings
    6 from django.test.utils import get_warnings_state, restore_warnings_state
    7 from django.utils.translation import _trans
    8 from django.utils.unittest import TestCase
    9 
    10 
    11 class DeprecationWarningTests(TestCase):
    12 
    13     def setUp(self):
    14         self.warning_state = get_warnings_state()
    15         self.old_settings_module = settings.SETTINGS_MODULE
    16         settings.SETTINGS_MODULE = 'regressiontests'
    17         self.old_locale_paths = settings.LOCALE_PATHS
    18 
    19     def tearDown(self):
    20         restore_warnings_state(self.warning_state)
    21         settings.SETTINGS_MODULE = self.old_settings_module
    22         settings.LOCALE_PATHS = self.old_locale_paths
    23 
    24     def test_warn_if_project_has_locale_subdir(self):
    25         """Test that DeprecationWarning is generated when a deprecated project level locale/ subdir is present."""
    26         project_path = join(dirname(abspath(__file__)), '..')
    27         warnings.filterwarnings('error',
    28                 "Translations in the project directory aren't supported anymore\. Use the LOCALE_PATHS setting instead\.",
    29                 DeprecationWarning)
    30         _trans.__dict__ = {}
    31         self.assertRaises(DeprecationWarning, django.utils.translation.ugettext, 'Time')
    32 
    33     def test_no_warn_if_project_and_locale_paths_overlap(self):
    34         """Test that DeprecationWarning isn't generated when a deprecated project level locale/ subdir is also included in LOCALE_PATHS."""
    35         project_path = join(dirname(abspath(__file__)), '..')
    36         settings.LOCALE_PATHS += (normpath(join(project_path, 'locale')),)
    37         warnings.filterwarnings('error',
    38                 "Translations in the project directory aren't supported anymore\. Use the LOCALE_PATHS setting instead\.",
    39                 DeprecationWarning)
    40         _trans.__dict__ = {}
    41         try:
    42             django.utils.translation.ugettext('Time')
    43         except DeprecationWarning:
    44             self.fail("DeprecationWarning shouldn't be raised when settings/project locale and a LOCALE_PATHS member point to the same file system location.")
  • tests/regressiontests/i18n/tests.py

    diff --git a/tests/regressiontests/i18n/tests.py b/tests/regressiontests/i18n/tests.py
    a b  
    4040    URLTranslationTests, URLDisabledTests, URLTagTests, URLTestCaseBase,
    4141    URLRedirectWithoutTrailingSlashSettingTests, URLNamespaceTests,
    4242    URLPrefixTests, URLResponseTests, URLRedirectTests, PathUnusedTests)
    43 from .test_warnings import DeprecationWarningTests
    4443
    4544
    4645here = os.path.dirname(os.path.abspath(__file__))
     
    869868        with self.settings(INSTALLED_APPS=extended_apps):
    870869            self.assertUgettext('Time', 'LOCALE_PATHS')
    871870
    872     def test_locale_paths_override_project_translation(self):
    873         with self.settings(SETTINGS_MODULE='regressiontests'):
    874             self.assertUgettext('Date/time', 'LOCALE_PATHS')
    875 
    876 class ProjectResolutionOrderI18NTests(ResolutionOrderI18NTests):
    877 
    878     def setUp(self):
    879         self.old_settings_module = settings.SETTINGS_MODULE
    880         settings.SETTINGS_MODULE = 'regressiontests'
    881         super(ProjectResolutionOrderI18NTests, self).setUp()
    882 
    883     def tearDown(self):
    884         settings.SETTINGS_MODULE = self.old_settings_module
    885         super(ProjectResolutionOrderI18NTests, self).tearDown()
    886 
    887     def test_project_translation(self):
    888         self.assertUgettext('Date/time', 'PROJECT')
    889 
    890     def test_project_override_app_translation(self):
    891         extended_apps = list(settings.INSTALLED_APPS) + ['regressiontests.i18n.resolution']
    892         with self.settings(INSTALLED_APPS=extended_apps):
    893             self.assertUgettext('Date/time', 'PROJECT')
    894 
    895871class DjangoFallbackResolutionOrderI18NTests(ResolutionOrderI18NTests):
    896872
    897873    def test_django_fallback(self):
  • deleted file tests/regressiontests/locale/de/LC_MESSAGES/django.po

    diff --git a/tests/regressiontests/locale/de/LC_MESSAGES/django.mo b/tests/regressiontests/locale/de/LC_MESSAGES/django.mo
    deleted file mode 100644
    Binary file tests/regressiontests/locale/de/LC_MESSAGES/django.mo has changed
    diff --git a/tests/regressiontests/locale/de/LC_MESSAGES/django.po b/tests/regressiontests/locale/de/LC_MESSAGES/django.po
    deleted file mode 100644
    + -  
    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 msgid ""
    7 msgstr ""
    8 "Project-Id-Version: django tests\n"
    9 "Report-Msgid-Bugs-To: \n"
    10 "POT-Creation-Date: 2010-02-14 17:33+0100\n"
    11 "PO-Revision-Date: 2011-02-07 13:13-0300\n"
    12 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
    13 "Language-Team: LANGUAGE <LL@li.org>\n"
    14 "MIME-Version: 1.0\n"
    15 "Content-Type: text/plain; charset=UTF-8\n"
    16 "Content-Transfer-Encoding: 8bit\n"
    17 "Plural-Forms: nplurals=2; plural=(n != 1)\n"
    18 
    19 #: models.py:3
    20 msgid "Time"
    21 msgstr "Zeit (PROJECT)"
    22 
    23 #: models.py:5
    24 msgid "Date/time"
    25 msgstr "Datum/Zeit (PROJECT)"
  • tests/runtests.py

    diff --git a/tests/runtests.py b/tests/runtests.py
    a b  
    2525TEMP_DIR = tempfile.mkdtemp(prefix='django_')
    2626os.environ['DJANGO_TEST_TEMP_DIR'] = TEMP_DIR
    2727
    28 REGRESSION_SUBDIRS_TO_SKIP = ['locale']
     28REGRESSION_SUBDIRS_TO_SKIP = []
    2929
    3030ALWAYS_INSTALLED_APPS = [
    3131    'django.contrib.contenttypes',
Back to Top