composeui.core.translation¶
Translate the text views show, from JSON catalogs.
A catalog is a <language>.json file mapping the text as written in the code to its
translation: {"Radius": "Rayon"}. Text missing from every catalog is shown as written,
like text translated as “”: a translation still to fill.
- composeui.core.translation.T¶
text to translate, as written in the code, wherever it’s declared:
add: ButtonView = child(ButtonView, text=T("Add"))
- class composeui.core.translation.TranslatedText[source]¶
Bases:
strText
View.trtranslated, remembering it as written to translate it again.MainView.set_languagetranslates it again wherever a view keeps it: in a field, a list (a table’s headers) or a dict’s keys (a choice’s labels). Formatting it keeps the arguments, to format the next translation with them. Other str methods return a plain str, which stays in its language.Built from
textalone (asT), it is the text as written. It is translated once a view keeps it and the main view sets a language. Use it for text declared where no view cantrit, e.g. a field’s default or a class variable.
- composeui.core.translation.translator(language, directories)[source]¶
Get the translation into
languagefrom the catalogs indirectories.The first directory with a translation of a text wins: an app’s catalogs, listed before ComposeUI’s, can change the text of ComposeUI’s views.
- Parameters:
language (str)
directories (Sequence[Path])
- Return type:
Translate