Skip to content

API turboframe.ui.language

rafageist edited this page Dec 4, 2026 · 4 revisions

turboframe.ui.language

Source: turboframe/ui/language.py. Generated from the code of TurboFrame 0.3.0 by tools/wiki_api.py.

Options > Language: the language of the interface, from the next start.

An application's texts are made when it starts (see turboframe.i18n), so the choice is kept in its store ("language") and applies the next time: the application passes it to choose_language(setting=...) when it starts. Each language is named in itself (English, Español), so anyone finds theirs.

An application mixes LanguageMixin into its DesktopApp, sets language_store (an object with load() -> dict and save(dict): its config) and language_domain (its turboframe.i18n.Domain), names its languages in LANGUAGES, and calls choose_language() from a worker (or language_command(command) for CM_LANGUAGE).

Contents

AUTO, CM_LANGUAGE, KEY, LANGUAGES, LanguageDialog, LanguageMixin, hotkey_label

AUTO

'auto'

CM_LANGUAGE

10306

KEY

'language'

LANGUAGES

{'auto': "~A~utomatic (the system's)", 'en': '~E~nglish', 'es': 'E~s~pañol'}

class LanguageDialog

class LanguageDialog(TVDialog)
LanguageDialog(codes: list[str], labels: list[str], current: str)

The languages (codes, named by labels) as radio buttons. chosen holds the code (auto, en, es...) once it ends with OK.

  • valid(command: Command) -> bool

class LanguageMixin

class LanguageMixin

Options > Language, mixed into a DesktopApp. The class attributes and hooks below have defaults; an application sets or overrides the ones that differ.

  • language_choices() -> list[str]: auto and the languages with a catalogue: the domain's, or TurboFrame's without one.
  • language_label(code: str) -> str: A language's name, from LANGUAGES (auto in the interface's language, TurboFrame's name for it when LANGUAGES has none), with a hotkey; the code itself for a language it does not name.
  • async language_saved(code: str) -> None: The choice was kept: say it applies from the next start.
  • language_setting() -> str: The language kept in the store (auto when there is none).
  • async choose_language() -> None: Run the dialog (from a worker); OK keeps a new choice in language_store.
  • async language_command(command: int) -> bool: Run CM_LANGUAGE (from a worker); False for another command.

hotkey_label

def hotkey_label(name: str) -> str

name with a hotkey: its own ~X~, else its first letter.

Clone this wiki locally