Add translation support for TUI help groups and binding descriptions#4363
Open
Softer wants to merge 2 commits intoarchlinux:masterfrom
Open
Add translation support for TUI help groups and binding descriptions#4363Softer wants to merge 2 commits intoarchlinux:masterfrom
Softer wants to merge 2 commits intoarchlinux:masterfrom
Conversation
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.
Torxed
approved these changes
Apr 2, 2026
Member
Torxed
left a comment
There was a problem hiding this comment.
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.
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.
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.