[Django] #35476: The precedence of multiple translations for the same literal does not work on Python3.11 & Python3.12

24 views
Skip to first unread message

Django

unread,
May 23, 2024, 5:02:19 AM5/23/24
to django-...@googlegroups.com
#35476: The precedence of multiple translations for the same literal does not work
on Python3.11 & Python3.12
-------------------------------------+-------------------------------------
Reporter: Dmytro | Owner: nobody
Litvinov |
Type: Bug | Status: new
Component: | Version: 4.2
Uncategorized |
Severity: Normal | Keywords: i18n, translation
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
According to documentation
https://docs.djangoproject.com/en/4.2/topics/i18n/translation/#how-django-
discovers-translations
Django will look for translations in the following order:

* LOCALE_PATHS directories
* 3rd party apps
* django/conf/locale

''I created example project with reproducing the issue at GitHub -
https://github.com/DmytroLitvinov/django-i18n-issue''

As for Python3.10 it works according to documentation, but if we start to
use Python3.11 and higher (like Python3.12) - we will see that the order
is not correct and it will take first from 3rd party app (like in my
example from django-allauth library).

To confirm that translation in LOCALE_PATHS are working correctly, we can
comment out 'allauth' in INSTALLED_APPS settings and see that translation
of word 'Continue' will be correctly taken from LOCALE_PATHS folders.
--
Ticket URL: <https://code.djangoproject.com/ticket/35476>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 23, 2024, 11:19:06 AM5/23/24
to django-...@googlegroups.com
#35476: The precedence of multiple translations for the same literal does not work
on Python3.11 & Python3.12
--------------------------------------+------------------------------------
Reporter: Dmytro Litvinov | Owner: nobody
Type: Bug | Status: new
Component: Internationalization | Version: 4.2
Severity: Normal | Resolution:
Keywords: i18n, translation | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Sarah Boyce):

* cc: Claude Paroz (added)
* component: Uncategorized => Internationalization
* stage: Unreviewed => Accepted

Comment:

Thank you for the report and the test project! Replicated and confirmed
this works on using Python 3.10
This appears to be a different issue to #34221 👍
--
Ticket URL: <https://code.djangoproject.com/ticket/35476#comment:1>

Django

unread,
Jun 8, 2024, 10:34:34 AM6/8/24
to django-...@googlegroups.com
#35476: The precedence of multiple translations for the same literal does not work
on Python3.11 & Python3.12
--------------------------------------+------------------------------------
Reporter: Dmytro Litvinov | Owner: nobody
Type: Bug | Status: new
Component: Internationalization | Version: 4.2
Severity: Normal | Resolution:
Keywords: i18n, translation | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Comment (by Vasyl Dizhak):

We've been working on this issue during the Sprints after the DjangoCon
Europe 2024 and this issue is related to #34221 as we can link it with the
same wrong behavior when comparing the plural functions.
Django uses the following plural function
{{{
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
}}}
which matches exactly with the one from the demo repository
https://github.com/DmytroLitvinov/django-i18n-
issue/blob/main/locale/de/LC_MESSAGES/django.po#L19C28-L19C43, therefore,
local translations will be merged into the first catalog together with
Django's translations.

The `allauth` package has a different plural function that would insert
it in the first position in the translation catalog
https://github.com/pennersr/django-
allauth/blob/main/allauth/locale/de/LC_MESSAGES/django.po#L20

{{{
"Plural-Forms: nplurals=2; plural=n != 1;\n"
}}}

`gettext` would check first the 3d-party `allauth` translations catalog as
it has higher precedence, and only then look at the merged one containing
the local files.
We propose to close it as a duplicate to the #34221.
--
Ticket URL: <https://code.djangoproject.com/ticket/35476#comment:2>

Django

unread,
Jun 8, 2024, 10:39:26 AM6/8/24
to django-...@googlegroups.com
#35476: The precedence of multiple translations for the same literal does not work
on Python3.11 & Python3.12
-------------------------------------+-------------------------------------
Reporter: Dmytro Litvinov | Owner: Vasyl
| Dizhak
Type: Bug | Status: assigned
Component: | Version: 4.2
Internationalization |
Severity: Normal | Resolution:
Keywords: i18n, translation | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Vasyl Dizhak):

* owner: nobody => Vasyl Dizhak
* status: new => assigned

--
Ticket URL: <https://code.djangoproject.com/ticket/35476#comment:3>

Django

unread,
Jun 8, 2024, 10:40:44 AM6/8/24
to django-...@googlegroups.com
#35476: The precedence of multiple translations for the same literal does not work
on Python3.11 & Python3.12
-------------------------------------+-------------------------------------
Reporter: Dmytro Litvinov | Owner: Vasyl
| Dizhak
Type: Bug | Status: assigned
Component: | Version: 4.2
Internationalization |
Severity: Normal | Resolution:
Keywords: i18n, translation | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Vasyl Dizhak):

* cc: Vasyl Dizhak (added)

--
Ticket URL: <https://code.djangoproject.com/ticket/35476#comment:4>

Django

unread,
Jun 8, 2024, 10:41:30 AM6/8/24
to django-...@googlegroups.com
#35476: The precedence of multiple translations for the same literal does not work
on Python3.11 & Python3.12
-------------------------------------+-------------------------------------
Reporter: Dmytro Litvinov | Owner: Vasyl
| Dizhak
Type: Bug | Status: assigned
Component: | Version: 4.2
Internationalization |
Severity: Normal | Resolution:
Keywords: i18n, translation | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by viktorparipas92):

* cc: viktorparipas92 (added)

--
Ticket URL: <https://code.djangoproject.com/ticket/35476#comment:5>

Django

unread,
Aug 27, 2024, 12:51:09 PM8/27/24
to django-...@googlegroups.com
#35476: The precedence of multiple translations for the same literal does not work
on Python3.11 & Python3.12
-------------------------------------+-------------------------------------
Reporter: Dmytro Litvinov | Owner: Vasyl
| Dizhak
Type: Bug | Status: closed
Component: | Version: 4.2
Internationalization |
Severity: Normal | Resolution: duplicate
Keywords: i18n, translation | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Claude Paroz):

* resolution: => duplicate
* status: assigned => closed

Comment:

Duplicate of #34221, as explained in comment:2, thanks Vasyl!
--
Ticket URL: <https://code.djangoproject.com/ticket/35476#comment:6>
Reply all
Reply to author
Forward
0 new messages