Skip to content

Commit dad01d3

Browse files
committed
Fix for wrong plurals with multiple domains
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 ckan/ckan#8258
1 parent 38a3458 commit dad01d3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

flask_babel/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ def get_translations(self):
630630
# does not copy _info, plural(), or any other instance variables
631631
# populated by GNUTranslations. We probably want to stop using
632632
# `support.Translations.merge` entirely.
633-
if hasattr(catalog, 'plural'):
633+
if catalog.info() and hasattr(catalog, 'plural'):
634634
translations.plural = catalog.plural
635635

636636
cache[str(locale), self.domain[0]] = translations

0 commit comments

Comments
 (0)