Skip to content

Add translation support for TUI help groups and binding descriptions#4363

Open
Softer wants to merge 2 commits intoarchlinux:masterfrom
Softer:translate-tui-help-labels
Open

Add translation support for TUI help groups and binding descriptions#4363
Softer wants to merge 2 commits intoarchlinux:masterfrom
Softer:translate-tui-help-labels

Conversation

@Softer
Copy link
Copy Markdown
Contributor

@Softer Softer commented Apr 2, 2026

Help group names shown via F1 (General, Navigation, Selection, Search) and key binding descriptions in the Textual footer (Down, Up, Cancel, Confirm, etc.) were hardcoded in English and never went through the translation system.

PR Description:

This adds tr() wrapping for help group titles and introduces a mechanism to translate Textual binding descriptions at runtime. The tricky part is that Textual evaluates bindings at class definition time (before any language is activated), and stores them as frozen dataclasses. To work around this, _translate_bindings() rebuilds binding objects on every change of screen, so now we always show the current language. The app-level bindings are also re-translated when the user switches language mid-session.

New translatable strings are added to base.pot and translated for Ukrainian.

Help group names shown via F1 (General, Navigation, Selection, Search) and key binding descriptions in the Textual footer (Down, Up, Cancel, Confirm, etc.) were hardcoded in English and never went through the translation system.
@Softer Softer requested a review from Torxed as a code owner April 2, 2026 17:34
Copy link
Copy Markdown
Member

@Torxed Torxed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't tested this, but the code looks good.
Only thing that worry me is that we're calling private functions on the widgets which might be subject to change in the future.
But I also recognize that textual might not have thought of this behavior during translations so, probably best option.

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