python-babel / flask-babel

i18n and l10n support for Flask based on Babel and pytz
https://python-babel.github.io/flask-babel/
Other
432 stars 159 forks source link

Fix for untranslated plurals when using multiple domains #241

Closed amercader closed 2 weeks ago

amercader commented 3 weeks ago

When translations from different catalogs are being merged, there is a workaround to copy the plurals() function from the catalog to the combined translations object. If the locale catalog doesn't exist for a particular domain, a default value is copied, overriding the proper plurals()function. This results in the plural version of a string not being translated for languages with different plural values.

See for instance test_gettext.py::test_plurals_different_domains: the Japanese locale exists only in the messages domain (translations folder) but not on the myapp one (translations_different_domain folder).

First reported in https://github.com/ckan/ckan/issues/8258

TkTech commented 2 weeks ago

Didn't get a chance to test this today as the CI tooling was out of date and had to be updated first. Will get to this tomorrow.

TkTech commented 2 weeks ago

@amercader Looks good, but there's a failure in the tests under pypy. Looks like the tests might be depending on the ordering of the translation list, https://github.com/python-babel/flask-babel/actions/runs/9577423964/job/26405619814