#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 | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Comment (by Claude Paroz):
Something like that:
{{{
diff --git a/django/utils/translation/trans_real.py
b/django/utils/translation/trans_real.py
index eed4705f6e..0dca4230d2 100644
--- a/django/utils/translation/trans_real.py
+++ b/django/utils/translation/trans_real.py
@@ -92,7 +92,7 @@ class TranslationCatalog:
def update(self, trans):
# Merge if plural function is the same, else prepend.
for cat, plural in zip(self._catalogs, self._plurals):
- if trans.plural.__code__ == plural.__code__:
+ if _plurals_equal(trans.plural, plural):
cat.update(trans._catalog)
break
else:
@@ -259,6 +259,17 @@ class
DjangoTranslation(gettext_module.GNUTranslations):
return tmsg
+def _plurals_equal(plur1, plur2):
+ """
+ Compare plural functions by comparing their result on 0 - 101.
+ Not perfect, but probably sufficient for our use case.
+ """
+ for num in range(102):
+ if plur1(num) != plur2(num):
+ return False
+ return True
+
+
def translation(language):
"""
Return a translation object in the default 'django' domain.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/31570#comment:13>
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/063.fd84f65972d835ffbc8a30ac391a7913%40djangoproject.com.