Code

Ticket #18395: 18395-1.diff

File 18395-1.diff, 686 bytes (added by claudep, 2 years ago)

Reset translation global variables with setting_changed

Line 
1diff --git a/django/test/signals.py b/django/test/signals.py
2index 81808df..d7d63e3 100644
3--- a/django/test/signals.py
4+++ b/django/test/signals.py
5@@ -46,3 +46,12 @@ def update_connections_time_zone(**kwargs):
6 def clear_context_processors_cache(**kwargs):
7     if kwargs['setting'] == 'TEMPLATE_CONTEXT_PROCESSORS':
8         context._standard_context_processors = None
9+
10+
11+@receiver(setting_changed)
12+def language_changed(**kwargs):
13+    if kwargs['setting'] in ('LOCALE_PATHS', 'LANGUAGE_CODE'):
14+        from django.utils.translation import trans_real
15+        trans_real._default = None
16+        if kwargs['setting'] == 'LOCALE_PATHS':
17+            trans_real._translations = {}