From 179fefcf7c1e9c6f0a4db5b31a4444bee24e73fa Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Sat, 12 Feb 2011 19:12:36 +0000 Subject: 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 --- django/utils/translation/__init__.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'django/utils') 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)) -- cgit v1.3