Skip to content

Validate single-form plurals against plural source placeholders - #1362

Open
yuefdev wants to merge 1 commit into
python-babel:masterfrom
yuefdev:fix-single-plural-placeholders
Open

yuefdev wants to merge 1 commit into
python-babel:masterfrom
yuefdev:fix-single-plural-placeholders

Conversation

@yuefdev

@yuefdev yuefdev commented Oct 3, 2026

Copy link
Copy Markdown

Related to #661.

A one-form plural translation is currently checked against the singular source. This rejects valid translations when the singular already contains a named placeholder and the plural introduces another:

python_format(
    Catalog('zh'),
    Message(
        ('One file for %(owner)s', '%(num)d files for %(owner)s'),
        ('%(owner)s: %(num)d',),
    ),
)
# TranslationError: unknown named placeholder 'num'

The original no-placeholder example in #661 already passes on master, but this variant still fails. Use the plural source for a plural message in a catalog with exactly one plural form. That translation is used for every count, including plural counts.

Regressions cover Chinese, Japanese and Korean, incompatible/unknown placeholders, and the existing singular validation in a two-form catalog. Four new cases fail before the fix.

Validation: python -m pytest tests/messages/test_checkers.py tests/messages/test_catalog.py -q --tb=short --show-capture=no — 92 passed. Configured pre-commit checks passed for both changed files.

AI assistance: Codex investigated the remaining failure, prepared the fix and tests, and ran these automated checks. No independent human review is claimed.

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