vacanza / holidays

Generate and work with holidays in Python
https://pypi.org/project/holidays
MIT License
1.45k stars 460 forks source link

Generate l10n file on per locale basis #1658

Open arkid15r opened 8 months ago

arkid15r commented 8 months ago

Currently we generate .po/.mo files for every entity. This approach is not ideal for l10n management and produces somewhat redundant l10n items. The better approach would be generate .po/.mo files on per locale basis. We need to consider switching to more simple mechanism and implement it when we have a chance. This would be a significant improvement for Weblate integration management too.

KJhellico commented 8 months ago

I have some ideas about new l10n layout. PO files use unified strings (derived from English name) as msgids. For holidays with the same name in all countries msgid begin with just "_" or some common prefix: "_new_years_day", "_good_friday", "_immaculate_conception" etc. However, in some countries, the names of common holidays differ. For them, we use separate msgid with country code prefix: "ar_immaculate_conception", "bg_independence_day" etc.

So PO files will contain:

en_US.po:

#. New Year's Day.
msgid "_new_years_day"
msgstr "New Year's Day"
...
#. Good Friday.
msgid "_good_friday"
msgstr "Good Friday"
...
#. Immaculate Conception.
msgid "_immaculate_conception"
msgstr "Immaculate Conception"
...
#. Immaculate Conception.
msgid "ar_immaculate_conception"
msgstr "Immaculate Conception"

#. Independence Day.
msgid "_independence_day"
msgstr "Independence Day"

#. Independence Day.
msgid "bg_independence_day"
msgstr "Independence Day"

(in en_US locale names for Immaculate Conception in Argentina and Independence Day in Bulgaria doesn't differ from common)

es.po:

#. New Year's Day.
msgid "_new_years_day"
msgstr "Año Nuevo"
...
#. Good Friday.
msgid "_good_friday"
msgstr "Viernes Santo"
...
#. Immaculate Conception.
msgid "_immaculate_conception"
msgstr "Inmaculada Concepción"
...
#. Immaculate Conception.
msgid "ar_immaculate_conception"
msgstr "Inmaculada Concepción de María"

(in es locale name for Immaculate Conception in Argentina is different)

bg.po:

...
#. Independence Day.
msgid "_independence_day"
msgstr "Ден на независимостта"
# or there is simply no translation, if we don't yet need Bulgarian translation of countries other than Bulgaria

#. Independence Day.
msgid "bg_independence_day"
msgstr "Ден на Независимостта на България"

(in bg locale name for Independence Day in Bulgaria is different)