#31570: Translations of one language in different territories can override each
other
------------------------------------------------+------------------------
Reporter: Shai Berger | Owner: nobody
Type: Bug | Status: new
Component: Internationalization | Version: 2.2
Severity: Release blocker | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------------+------------------------
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):
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/31570>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/048.d4eac1b6a7e18b1513fb3a65cb5b89dd%40djangoproject.com.