Skip to content

Extract TUI binding descriptions into base.pot and translate raw widget bindings#4587

Open
Softer wants to merge 1 commit into
archlinux:masterfrom
Softer:fix-locales-binding-strings
Open

Extract TUI binding descriptions into base.pot and translate raw widget bindings#4587
Softer wants to merge 1 commit into
archlinux:masterfrom
Softer:fix-locales-binding-strings

Conversation

@Softer

@Softer Softer commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Fixes #4584.

The help bar and F1 panel strings never made it into base.pot: they are binding descriptions translated at runtime from a variable (tr(b.description)), and xgettext only knew the literal tr("...") form. #4363 worked around that by adding the strings to base.pot manually, but the regeneration in #4557 wiped them again (and with the freshness check gone since #4576, nothing noticed).

What's here:

  • locales_generator.sh passes two more keywords to xgettext: Binding:3 extracts the description argument of our own Binding() definitions, tr_noop marks strings that exist only inside the textual package.
  • New tui/binding_descriptions.py lists those textual built-ins. The list covers the full MRO of the widgets we use - _translate_bindings() works on the merged bindings map, so inherited descriptions like "Scroll Up" are translated at runtime too. They carry live translations in 18 locales today; leaving them out of the pot would have obsoleted those on the next msgmerge.
  • Raw Input and Button widgets never went through _translate_bindings(), so their help-panel descriptions stayed English no matter what was in the .po - subclassed them (_Input/_Button) following the existing _OptionList pattern.
  • test_tooling/check_binding_descriptions.py - a small manual checker to re-verify the list after a textual upgrade (not wired into CI).

Note: the pot regen also picks up the three Plymouth strings from #4555 - master's pot simply hadn't been regenerated since that merge.

…indings (archlinux#4584)

xgettext only knew the tr keyword, so binding descriptions - translated
at runtime via tr(b.description) in _translate_bindings() - never made
it into base.pot. The strings added manually in archlinux#4363 were wiped by the
regeneration in archlinux#4557.

Teach the generator two more keywords: Binding:3 picks up our own
binding definitions, and tr_noop marks strings that only exist inside
the textual package, listed in the new tui/binding_descriptions.py.
The list walks the full MRO of the textual classes used in components.py,
since _translate_bindings() operates on the merged bindings map (e.g.
Scroll Up comes from ScrollView and carries live translations in 18
locales today).

Raw Input and Button widgets never went through _translate_bindings(),
so their help-panel descriptions stayed English regardless of .po
content - subclass them (_Input/_Button) following the _OptionList
pattern to make those translations real.

test_tooling/check_binding_descriptions.py verifies the list against
the installed textual after upgrades (manual, not wired into CI).
@Softer Softer requested a review from Torxed as a code owner June 10, 2026 13:51
@Softer

Softer commented Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

The mypy job died on infra - Docker Hub timed out while pulling the container, mypy itself never ran (it passes locally). Could someone with the button re-run the failed job?

@Torxed

Torxed commented Jun 10, 2026

Copy link
Copy Markdown
Member

Yeah the infra somewhat often dies and runner results geta screwed. Those are fine, I manually check them usually or re-run from admin panel on GH.

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.

Some strings aren't being generated by locales_generator.sh

2 participants