diff options
| author | Jannis Leidel <jannis@leidel.info> | 2011-02-12 19:12:36 +0000 |
|---|---|---|
| committer | Jannis Leidel <jannis@leidel.info> | 2011-02-12 19:12:36 +0000 |
| commit | 179fefcf7c1e9c6f0a4db5b31a4444bee24e73fa (patch) | |
| tree | 8780b9d3be561215a98d21a212c1086927476d77 /django/utils/translation/__init__.py | |
| parent | e1e3f243715c400bc6e2cec5bd650ac90ecb7f44 (diff) | |
Fixed #15286 -- Don't show deprecation warning if project locale dir is included in LOCALE_PATHS. Thanks to Claude and Ramiro.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15508 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/utils/translation/__init__.py')
| -rw-r--r-- | django/utils/translation/__init__.py | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/django/utils/translation/__init__.py b/django/utils/translation/__init__.py index e44b556c16..992e1c9664 100644 --- a/django/utils/translation/__init__.py +++ b/django/utils/translation/__init__.py @@ -1,6 +1,7 @@ """ Internationalization support. """ +import warnings from os import path from django.utils.encoding import force_unicode @@ -41,17 +42,20 @@ class Trans(object): from django.conf import settings if settings.USE_I18N: from django.utils.translation import trans_real as trans - + # Make sure the project's locale dir isn't in LOCALE_PATHS if settings.SETTINGS_MODULE is not None: - import warnings parts = settings.SETTINGS_MODULE.split('.') project = import_module(parts[0]) - if path.isdir(path.join(path.dirname(project.__file__), 'locale')): - warnings.warn( - "Translations in the project directory aren't supported anymore. Use the LOCALE_PATHS setting instead.", - PendingDeprecationWarning - ) - + project_locale_path = path.normpath( + path.join(path.dirname(project.__file__), 'locale')) + normalized_locale_paths = [path.normpath(locale_path) + for locale_path in settings.LOCALE_PATHS] + if (path.isdir(project_locale_path) and + not project_locale_path in normalized_locale_paths): + warnings.warn("Translations in the project directory " + "aren't supported anymore. Use the " + "LOCALE_PATHS setting instead.", + PendingDeprecationWarning) else: from django.utils.translation import trans_null as trans setattr(self, real_name, getattr(trans, real_name)) |
