imp: i18n: ignore user catalog translations with wrong placeholders, with a warning - #2760
Merged
Merged
Conversation
…ignored, with a warning
A translation in a user catalog (~/.config/hledger/locale/LANG.po) that
does not have exactly its English text's {placeholders} is now ignored,
and hledger warns, naming each such translation and its placeholders.
The built-in translation, or the English text, is shown instead, and the
rest of the catalog is still used. Before, such a translation was used
as is, silently dropping filled-in values (a report title lost its
dates) or showing a misspelled placeholder literally ("{bogus} Bilanz").
Poedit and Weblate already warn about this; this covers catalogs edited
by hand.
A plural form may have only its English text's placeholders and {n}.
The built-in catalogs' unit test now uses the same check.
AI usage: Claude Opus 5.5, ~18k output tokens
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A translation in a user catalog (
~/.config/hledger/locale/LANG.po) that doesn't have exactly its English text's{placeholders}is now ignored, with a warning naming each such translation. The built-in translation, or the English text, is shown instead, and the rest of the catalog is still used.Before, such a translation was used as is. A report title could silently lose its dates, or show a misspelled placeholder literally. For example, a German catalog translating the title template as
"{bogus} {report}"gave:Now it gives:
Poedit and Weblate already warn about missing placeholders; this covers catalogs edited by hand, which doc/TRANSLATING.md says is fine.
Details:
{n}. It's now one function, used both when loading a user catalog and by the built-in catalogs' unit test.{n}isn't rejected, and a bad plural entry is removed from both places.Tests: a new unit test covers good and bad messages and plurals and the warning text. Unit tests,
hledger/test/i18n.testandjust i18n-checkpass. A functional test would need a small catalog fixture used throughXDG_CONFIG_HOME; I can add one if wanted.AI usage: Claude Opus 5.5, ~18k output tokens