﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
31570	Translations of one language in different territories can override each other	Shai Berger	Carlton Gibson	"The fix of #30439 created a new problem: Under some circumstances, translations for one language in different territories can override each other. In the case we've run into, users in New Zealand ({{{en-NZ}}}) received translations for South Africa ({{{en-ZA}}}). We've seen this behavior on 2.2.12, and downgrading to 2.2.11 resolved it, hence marking this as a bug in 2.2, but I believe the same issue exists in 3.0 and master.

The circumstances where this happens are not trivial to reproduce; it involves having applications with translations for the ""bare"" language ({{{en}}} in our case), and may depend on the order of loading of different translations. I will try to come up with a test later.

The issue arises, AFAICT, when the {{{TranslationCatalog}}} installs a reference to the bare-language dictionary (""catalog"" in gettext terms) as the first in the list of catalogs for a territorial variation (when an app has only the bare-language translation), and is then willing to update it with the contents of another territorial variant.

The following diff seems to resolve the issue, but I am far from certain that it is the right solution.

{{{#!diff
diff --git a/django/utils/translation/trans_real.py b/django/utils/translation/trans_real.py
index eed4705f6e..8042f6fdc4 100644
--- a/django/utils/translation/trans_real.py
+++ b/django/utils/translation/trans_real.py
@@ -96,7 +96,7 @@ class TranslationCatalog:
                 cat.update(trans._catalog)
                 break
         else:
-            self._catalogs.insert(0, trans._catalog)
+            self._catalogs.insert(0, trans._catalog.copy())
             self._plurals.insert(0, trans.plural)
 
     def get(self, key, default=None):
}}}"	Bug	closed	Internationalization	2.2	Release blocker	fixed		Claude Paroz	Ready for checkin	1	0	0	0	0	0
