Code

Ticket #15286: 15286.diff

File 15286.diff, 903 bytes (added by claudep, 3 years ago)

Don't show PendingDeprecationWarning if path is in LOCALE_PATHS

Line 
1diff --git a/django/utils/translation/__init__.py b/django/utils/translation/__init__.py
2index e44b556..a1c8995 100644
3--- a/django/utils/translation/__init__.py
4+++ b/django/utils/translation/__init__.py
5@@ -46,7 +46,8 @@ class Trans(object):
6                 import warnings
7                 parts = settings.SETTINGS_MODULE.split('.')
8                 project = import_module(parts[0])
9-                if path.isdir(path.join(path.dirname(project.__file__), 'locale')):
10+                project_locale_path = path.normpath(path.join(path.dirname(project.__file__), 'locale'))
11+                if path.isdir(project_locale_path) and not project_locale_path in settings.LOCALE_PATHS:
12                     warnings.warn(
13                         "Translations in the project directory aren't supported anymore. Use the LOCALE_PATHS setting instead.",
14                         PendingDeprecationWarning