diff options
Diffstat (limited to 'django')
| -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)) |
