Skip to content

Preserve empty message contexts in PO and MO output - #1373

Open
fhgffy wants to merge 1 commit into
python-babel:masterfrom
fhgffy:fix/empty-message-context
Open

fhgffy wants to merge 1 commit into
python-babel:masterfrom
fhgffy:fix/empty-message-context

Conversation

@fhgffy

@fhgffy fhgffy commented Oct 9, 2026

Copy link
Copy Markdown

GNU gettext distinguishes an empty context from an absent msgctxt, and Catalog stores both entries separately. The PO and MO writers currently omit an empty context, so messages sharing an ID are merged or lost when the output is read. Check whether context is None in the regular singular/plural serialization branches. Add PO/MO roundtrips for absent, empty, and named contexts, and verify translated lookup results.

Validation: all three new regressions fail before the change; 41 PO/MO tests and the complete suite (7,831 passed, 10 skipped, 2 xfailed) pass afterward. Project Ruff checks, whitespace/debug hooks, and sdist/wheel builds passed. Tests use the Makefile's python -X utf8 flag and the project's imported CLDR 48.2 data.

Specification: https://www.gnu.org/software/gettext/manual/html_node/Entries-with-Context.html

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