Skip to content

Explain how to combine translation catalogs with different plural rules - #1542

Open
anlonely wants to merge 1 commit into
python-babel:masterfrom
anlonely:docs/catalog-plural-fallback
Open

anlonely wants to merge 1 commit into
python-babel:masterfrom
anlonely:docs/catalog-plural-fallback

Conversation

@anlonely

@anlonely anlonely commented Dec 6, 2026

Copy link
Copy Markdown

The example in the support guide merges a plugin's translations into the main catalog. If the catalogs use different plural rules, that can silently return untranslated text, even when both are French.

This documents an alternative for the runtime case in #1506. Looking in the plugin first and using the main catalog as a fallback preserves the plugin's priority while letting each catalog choose its own plural index. This doesn't change Translations.merge() or the pybabel concat behavior discussed in #1507.

I ran the examples extracted from the built HTML with a plugin MO generated by Babel 2.18.0 and a main MO generated by master (3a7d239). For a count of 2, the merged lookup returned tickets and the fallback lookup returned billets. I also checked overlapping messages, context-specific translations and missing entries.

python -m sphinx -W --keep-going -b html docs <output> and python -m pytest -q tests/test_support_translations.py tests/messages/test_mofile.py passed on Python 3.13. I didn't run the full platform matrix.

OpenAI Codex reproduced the issue, wrote and tested the examples, and drafted this PR.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant