Skip to content

fix: tools: i18n-extract finds tr calls made through local helpers - #2755

Merged
simonmichael merged 2 commits into
hledgerorg:mainfrom
acinader:i18n-extract-fix
Sep 30, 2026
Merged

simonmichael merged 2 commits into
hledgerorg:mainfrom
acinader:i18n-extract-fix

Conversation

@acinader

@acinader acinader commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Two fixes to the catalog extractor, both from the #2736 follow-up:

  • It finds tr calls made through local helpers. Since the CLI renderers bind tr = I18n.tr translations_ locally, their calls read tr "text", without the Translations argument the extractor required; it stopped seeing 28 strings, and just i18n-check reported them stale. just i18n-pot would have dropped them from the template. The argument is now optional.
  • It writes source references without line numbers. The template's #: lines now name only the source files a text appears in, like xgettext's --add-location=file, so the template changes only when strings are added, removed, or move to another file, and branches that regenerate it stop conflicting.

If this goes in first, the open web PRs (#2749, #2753, #2754) no longer need to touch the template at all; I've rebased them that way.

Test plan

  1. On main, just i18n-check reports 28 stale entries:

    hledger-lib/locale/de.po: 263 entries, 0 untranslated, 0 missing from catalog, 28 stale
    

    On this branch it reports none:

    hledger-lib/locale/de.po: 263 entries, 0 untranslated, 0 missing from catalog, 0 stale
    
  2. just i18n-pot leaves hledger-lib/locale/hledger.pot unchanged, and its #: lines carry file names only, eg #: hledger/Hledger/Cli/CompoundBalanceCommand.hs.

  3. Add a blank line near the top of any source file with translatable strings, eg hledger/Hledger/Cli/CompoundBalanceCommand.hs, and run just i18n-pot again: the template is still unchanged.

Since the CLI renderers bind `tr = I18n.tr translations_` locally, their
calls read `tr "text"`, without the Translations argument the extractor
required; it stopped seeing 29 strings and `just i18n-check` reported
them stale. The argument is now optional, and the template is regenerated.

AI usage: Claude Fable 5.1, ~1k output tokens.
The template's #: lines now name only the source files a text appears in.

With line numbers, any change that shifted code rewrote hundreds of references
on the next regeneration, so every branch that regenerated the template
conflicted with every other (hledgerorg#2736 review). Now the template changes only when
strings are added, removed, or move to another file.

AI usage: Claude Opus 5.5, ~1k output tokens.
@simonmichael
simonmichael merged commit dac870f into hledgerorg:main Sep 30, 2026
2 checks passed
@acinader
acinader deleted the i18n-extract-fix branch September 30, 2026 13:38
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.

2 participants