ticket/34869
When we run makemessages
- if there is a duplicate msgid
in a specific locale - if the translations (msgstr
) are identical in all cases - remove the duplicate msgid
and don’t display warnings or errors. Currently, a duplicate message definition
error is displayed and the duplicate msgid
is not removed. I have to check if the translations are identical and remove the duplicates manually. If the translations are identical, I don’t see any advantage in displaying an error message, and I prefer that the duplicates will be removed automatically.
Concrete example - I defined languages in my setting files:
In my base setting file:
LANGUAGES = [
('en', _('English')),
('he', _('Hebrew')),
]
And in another setting file, which is used only by 2 out of 4 sites:
LANGUAGES_TO_ADD = [
('fr', _('French')),
('de', _('German')),
('es', _('Spanish')),
('pt', _('Portuguese')),
('it', _('Italian')),
]
LANGUAGES = LANGUAGES[:1] + LANGUAGES_TO_ADD + LANGUAGES[1:]
The languages are created in my po files and are translated (for example to German):
#: .\settings\base.py:167
msgid "English"
msgstr "Englisch"
#: .\settings\base.py:168
msgid "Hebrew"
msgstr "Hebräisch"
#: .\settings\base_with_login.py:64
msgid "French"
msgstr "Französisch"
#: .\settings\base_with_login.py:65
msgid "German"
msgstr "Deutsch"
#: .\settings\base_with_login.py:66
msgid "Spanish"
msgstr "Spanisch"
#: .\settings\base_with_login.py:67
msgid "Portuguese"
msgstr "Portugiesisch"
#: .\settings\base_with_login.py:68
msgid "Italian"
msgstr "Italienisch"
Now, I’m adding 4 more languages in the setting file:
LANGUAGES_TO_ADD = [
('fr', _('French')),
('de', _('German')),
('es', _('Spanish')),
('pt', _('Portuguese')),
('it', _('Italian')),
('nl', _('Dutch')),
('sv', _('Swedish')),
('ko', _('Korean')),
('fi', _('Finnish')),
]
(the last 4 languages are new)
makemessages creates all the strings in my po files:
#: .\settings\base.py:167
msgid "English"
msgstr "Englisch"
#: .\settings\base.py:168
msgid "Hebrew"
msgstr "Hebräisch"
#: .\settings\base_with_login.py:64
msgid "French"
msgstr "Französisch"
#: .\settings\base_with_login.py:65
msgid "German"
msgstr "Deutsch"
#: .\settings\base_with_login.py:66
msgid "Spanish"
msgstr "Spanisch"
#: .\settings\base_with_login.py:67
msgid "Portuguese"
msgstr "Portugiesisch"
#: .\settings\base_with_login.py:68
msgid "Italian"
msgstr "Italienisch"
#: .\settings\base_with_login.py:69
msgid "Dutch"
msgstr ""
#: .\settings\base_with_login.py:70
msgid "Swedish"
msgstr ""
#: .\settings\base_with_login.py:71
msgid "Korean"
msgstr ""
#: .\settings\base_with_login.py:72
msgid "Finnish"
msgstr ""
Now, Django already contains these strings in /django/django/blob/main/django/conf/locale/de/LC_MESSAGES/django.po
I want to copy from there all the languages, run makemessages and then remove the languages not used. But if I don’t remove all the strings from my po files, I get duplicates. Even that the translated strings are the same.
By the way, maybe makemessage should not add the strings at all since they are already translated in
/django/django/blob/main/django/conf/locale/de/LC_MESSAGES/django.po ? And this is relevant to many strings (not only languages) - sometimes they are translated by Django but they also appear in my po files and I have to translate them again.