Code

Ticket #18040: 18040.diff

File 18040.diff, 8.3 KB (added by ramiro, 2 years ago)
Line 
1diff --git a/django/utils/translation/__init__.py b/django/utils/translation/__init__.py
2--- a/django/utils/translation/__init__.py
3+++ b/django/utils/translation/__init__.py
4@@ -1,12 +1,8 @@
5 """
6 Internationalization support.
7 """
8-import warnings
9-from os import path
10-
11 from django.utils.encoding import force_unicode
12 from django.utils.functional import lazy
13-from django.utils.importlib import import_module
14 
15 
16 __all__ = [
17@@ -47,20 +43,6 @@
18         from django.conf import settings
19         if settings.USE_I18N:
20             from django.utils.translation import trans_real as trans
21-            # Make sure the project's locale dir isn't in LOCALE_PATHS
22-            if settings.SETTINGS_MODULE is not None:
23-                parts = settings.SETTINGS_MODULE.split('.')
24-                project = import_module(parts[0])
25-                project_locale_path = path.normpath(
26-                    path.join(path.dirname(project.__file__), 'locale'))
27-                normalized_locale_paths = [path.normpath(locale_path)
28-                    for locale_path in settings.LOCALE_PATHS]
29-                if (path.isdir(project_locale_path) and
30-                        not project_locale_path in normalized_locale_paths):
31-                    warnings.warn("Translations in the project directory "
32-                                  "aren't supported anymore. Use the "
33-                                  "LOCALE_PATHS setting instead.",
34-                                  DeprecationWarning)
35         else:
36             from django.utils.translation import trans_null as trans
37         setattr(self, real_name, getattr(trans, real_name))
38diff --git a/django/utils/translation/trans_real.py b/django/utils/translation/trans_real.py
39--- a/django/utils/translation/trans_real.py
40+++ b/django/utils/translation/trans_real.py
41@@ -111,13 +111,6 @@
42 
43     globalpath = os.path.join(os.path.dirname(sys.modules[settings.__module__].__file__), 'locale')
44 
45-    if settings.SETTINGS_MODULE is not None:
46-        parts = settings.SETTINGS_MODULE.split('.')
47-        project = import_module(parts[0])
48-        projectpath = os.path.join(os.path.dirname(project.__file__), 'locale')
49-    else:
50-        projectpath = None
51-
52     def _fetch(lang, fallback=None):
53 
54         global _translations
55@@ -163,11 +156,6 @@
56             if os.path.isdir(apppath):
57                 res = _merge(apppath)
58 
59-        localepaths = [os.path.normpath(path) for path in settings.LOCALE_PATHS]
60-        if (projectpath and os.path.isdir(projectpath) and
61-                os.path.normpath(projectpath) not in localepaths):
62-            res = _merge(projectpath)
63-
64         for localepath in reversed(settings.LOCALE_PATHS):
65             if os.path.isdir(localepath):
66                 res = _merge(localepath)
67diff --git a/tests/regressiontests/i18n/test_warnings.py b/tests/regressiontests/i18n/test_warnings.py
68deleted file mode 100644
69--- a/tests/regressiontests/i18n/test_warnings.py
70+++ /dev/null
71@@ -1,44 +0,0 @@
72-import warnings
73-from os.path import join, normpath, abspath, dirname
74-
75-import django
76-from django.conf import settings
77-from django.test.utils import get_warnings_state, restore_warnings_state
78-from django.utils.translation import _trans
79-from django.utils.unittest import TestCase
80-
81-
82-class DeprecationWarningTests(TestCase):
83-
84-    def setUp(self):
85-        self.warning_state = get_warnings_state()
86-        self.old_settings_module = settings.SETTINGS_MODULE
87-        settings.SETTINGS_MODULE = 'regressiontests'
88-        self.old_locale_paths = settings.LOCALE_PATHS
89-
90-    def tearDown(self):
91-        restore_warnings_state(self.warning_state)
92-        settings.SETTINGS_MODULE = self.old_settings_module
93-        settings.LOCALE_PATHS = self.old_locale_paths
94-
95-    def test_warn_if_project_has_locale_subdir(self):
96-        """Test that DeprecationWarning is generated when a deprecated project level locale/ subdir is present."""
97-        project_path = join(dirname(abspath(__file__)), '..')
98-        warnings.filterwarnings('error',
99-                "Translations in the project directory aren't supported anymore\. Use the LOCALE_PATHS setting instead\.",
100-                DeprecationWarning)
101-        _trans.__dict__ = {}
102-        self.assertRaises(DeprecationWarning, django.utils.translation.ugettext, 'Time')
103-
104-    def test_no_warn_if_project_and_locale_paths_overlap(self):
105-        """Test that DeprecationWarning isn't generated when a deprecated project level locale/ subdir is also included in LOCALE_PATHS."""
106-        project_path = join(dirname(abspath(__file__)), '..')
107-        settings.LOCALE_PATHS += (normpath(join(project_path, 'locale')),)
108-        warnings.filterwarnings('error',
109-                "Translations in the project directory aren't supported anymore\. Use the LOCALE_PATHS setting instead\.",
110-                DeprecationWarning)
111-        _trans.__dict__ = {}
112-        try:
113-            django.utils.translation.ugettext('Time')
114-        except DeprecationWarning:
115-            self.fail("DeprecationWarning shouldn't be raised when settings/project locale and a LOCALE_PATHS member point to the same file system location.")
116diff --git a/tests/regressiontests/i18n/tests.py b/tests/regressiontests/i18n/tests.py
117--- a/tests/regressiontests/i18n/tests.py
118+++ b/tests/regressiontests/i18n/tests.py
119@@ -40,7 +40,6 @@
120     URLTranslationTests, URLDisabledTests, URLTagTests, URLTestCaseBase,
121     URLRedirectWithoutTrailingSlashSettingTests, URLNamespaceTests,
122     URLPrefixTests, URLResponseTests, URLRedirectTests, PathUnusedTests)
123-from .test_warnings import DeprecationWarningTests
124 
125 
126 here = os.path.dirname(os.path.abspath(__file__))
127@@ -869,29 +868,6 @@
128         with self.settings(INSTALLED_APPS=extended_apps):
129             self.assertUgettext('Time', 'LOCALE_PATHS')
130 
131-    def test_locale_paths_override_project_translation(self):
132-        with self.settings(SETTINGS_MODULE='regressiontests'):
133-            self.assertUgettext('Date/time', 'LOCALE_PATHS')
134-
135-class ProjectResolutionOrderI18NTests(ResolutionOrderI18NTests):
136-
137-    def setUp(self):
138-        self.old_settings_module = settings.SETTINGS_MODULE
139-        settings.SETTINGS_MODULE = 'regressiontests'
140-        super(ProjectResolutionOrderI18NTests, self).setUp()
141-
142-    def tearDown(self):
143-        settings.SETTINGS_MODULE = self.old_settings_module
144-        super(ProjectResolutionOrderI18NTests, self).tearDown()
145-
146-    def test_project_translation(self):
147-        self.assertUgettext('Date/time', 'PROJECT')
148-
149-    def test_project_override_app_translation(self):
150-        extended_apps = list(settings.INSTALLED_APPS) + ['regressiontests.i18n.resolution']
151-        with self.settings(INSTALLED_APPS=extended_apps):
152-            self.assertUgettext('Date/time', 'PROJECT')
153-
154 class DjangoFallbackResolutionOrderI18NTests(ResolutionOrderI18NTests):
155 
156     def test_django_fallback(self):
157diff --git a/tests/regressiontests/locale/de/LC_MESSAGES/django.mo b/tests/regressiontests/locale/de/LC_MESSAGES/django.mo
158deleted file mode 100644
159Binary file tests/regressiontests/locale/de/LC_MESSAGES/django.mo has changed
160diff --git a/tests/regressiontests/locale/de/LC_MESSAGES/django.po b/tests/regressiontests/locale/de/LC_MESSAGES/django.po
161deleted file mode 100644
162--- a/tests/regressiontests/locale/de/LC_MESSAGES/django.po
163+++ /dev/null
164@@ -1,25 +0,0 @@
165-# SOME DESCRIPTIVE TITLE.
166-# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
167-# This file is distributed under the same license as the PACKAGE package.
168-# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
169-#
170-msgid ""
171-msgstr ""
172-"Project-Id-Version: django tests\n"
173-"Report-Msgid-Bugs-To: \n"
174-"POT-Creation-Date: 2010-02-14 17:33+0100\n"
175-"PO-Revision-Date: 2011-02-07 13:13-0300\n"
176-"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
177-"Language-Team: LANGUAGE <LL@li.org>\n"
178-"MIME-Version: 1.0\n"
179-"Content-Type: text/plain; charset=UTF-8\n"
180-"Content-Transfer-Encoding: 8bit\n"
181-"Plural-Forms: nplurals=2; plural=(n != 1)\n"
182-
183-#: models.py:3
184-msgid "Time"
185-msgstr "Zeit (PROJECT)"
186-
187-#: models.py:5
188-msgid "Date/time"
189-msgstr "Datum/Zeit (PROJECT)"
190diff --git a/tests/runtests.py b/tests/runtests.py
191--- a/tests/runtests.py
192+++ b/tests/runtests.py
193@@ -25,7 +25,7 @@
194 TEMP_DIR = tempfile.mkdtemp(prefix='django_')
195 os.environ['DJANGO_TEST_TEMP_DIR'] = TEMP_DIR
196 
197-REGRESSION_SUBDIRS_TO_SKIP = ['locale']
198+REGRESSION_SUBDIRS_TO_SKIP = []
199 
200 ALWAYS_INSTALLED_APPS = [
201     'django.contrib.contenttypes',