#32373 closed Bug (worksforme)
Broken translations since the introduction of TranslationCatalog
Reported by: | Hristo Gatsinski | Owned by: | nobody |
---|---|---|---|
Component: | Internationalization | Version: | dev |
Severity: | Normal | Keywords: | translations |
Cc: | Claude Paroz, Carlton Gibson | Triage Stage: | Unreviewed |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
I recently updated one of my projects from the latest patch version of 2.2 to 3.1 and noticed that one of the translations is broken. When I translate "All" to Bulgarian it should output "Всичко" but instead, I get "Все" which I believe is in Russian. The PO files in Django are correct, and I have the same string translated in my project too. Both with the correct msgstr.
I managed to track the issue to the introduction of TranslationCatalog in 3.0.5 in this commit:
https://github.com/django/django/commit/d9f1792c7649e9f946f4a3a35a76bddf5a412b8b
Replacing _catalog from TranslationCatalog() to normal Python dict (as it used to be in 3.0.4 and prior) resolves the issue.
The issue continues to exist in the latest 3.1 and the pre-release 3.2a1.
I use Linux Mint 20.1 based on Ubuntu 20.04. For a while I suspected gettext. The last version available via apt is 0.19.8.1 but I also installed the latest from source (0.21). The issue still exists.
The bug is easy to reproduce.
Enter the shell of any project with Django 3.0.4 and older and execute the following:
from django.utils import translation
translation.activate('bg')
translation.gettext('All')
You will see "Всичко".
Do the same with Django 3.0.5 and above and you will get "Все" which is an incorrect translation. It doesn't matter if you are using gettext, ugettext, ugettext_lazy, etc.
I failed to find an existing ticket describing this problem. Forgive me if there is one already.
Change History (4)
comment:1 by , 4 years ago
Description: | modified (diff) |
---|
comment:2 by , 4 years ago
Cc: | added |
---|---|
Easy pickings: | unset |
comment:3 by , 4 years ago
Resolution: | → worksforme |
---|---|
Status: | new → closed |
comment:4 by , 4 years ago
Hi, Carlton.
I'm so sorry for the trouble. It was getting late yesterday I didn't bother to check if the issue exists in a fresh project. And it doesn't. I started investigating it against my project and I found out that the cause is not Django but django-filter. Before opening the ticket I tested my third party libraries by downgrading them to the version prior to the update but somehow I missed it. I also had to downgrade Django and maybe this is how I got confused. Or maybe I just really wanted to find a problem within Django and feel good for helping the community. Well, it didn't turn out as I expected.
I created a fresh project with only django-filter installed, with a simple test and CircleCI integration to verify the problem.
The repository is available here - https://github.com/gatsinski/django-filters-translation-issue
The failing CI job can be found here - https://app.circleci.com/pipelines/github/gatsinski/django-filters-translation-issue/3/workflows/4e5e56b0-39a2-4f74-888e-e1fa0c7e090c/jobs/3
Tonight I will check the docs of django-filter and browse the changes to see if there is something related between 2.2 and 2.4 and if not, I will open another ticket there.
And once again, sorry for the trouble. I shouldn't open tickets that late. Forget about this one and we will probably speak again on django-filter's GitHub repo.
Hi Hristo
Thanks for the report. Can I ask you to dig a bit more since I can't reproduce as described.
Here's a full transcript showing, creation of a project with Django 3.0.4, with the expected result, but the same output for 3.0.5 and 3.1.5:
Really very happy to look into the issue here (no problem with the new ticket! :) but what have I done wrong to not reproduce it?
Thanks!