Localization
Settings (v0.2.2)
Settings ships with built-in UI strings for 16 languages, and strings within the schema can be localized using the same mechanism.
lang
| Value | Behavior |
|---|---|
"os" | Resolved in order: the parent app's lang_key, then the OS language setting |
| BCP-47 code | Forces a specific language (e.g. "ja", "de"). Language codes without built-in translations fall back to English |
lang controls the display language for both the built-in UI translations and the localization tables in the schema. See Built-in 16 languages below for the list of supported language codes.
lang_key
lang = "os"
lang_key = "display.language"When lang = "os", Settings reads the config key given by lang_key from the parent app's config file and matches its UI language to it. Since Settings is a tool for editing the parent app's configuration, it's natural for it to follow the parent app's own language setting. If no value can be obtained via lang_key, or there is no corresponding language, it falls back to the OS language setting.
[ui_strings]
Built-in UI strings (OK, Cancel, Browse…, etc.) can be individually overridden from the schema. For the list of keys, see UiStrings in the codebase (settings-schema/src/lib.rs). Some representative ones:
| Key | Purpose |
|---|---|
ok / cancel / apply | Buttons in the save bar |
browse | File selection button |
add / delete / delete_confirm | Adding/removing subsections |
reload / keep_editing / file_changed | External change conflict dialog |
window_title | Window title bar string |
[ui_strings]
window_title = "My App Settings"delete_confirm is a template string for the deletion confirmation dialog; {} is replaced with the name of the item being deleted (e.g. "Delete \"{}\"?").
For any key without an override, the built-in translation is used as-is.
Localizing schema strings
User-facing strings such as tab and field labels can be written either as a bare string (shared across all languages) or as an inline table keyed by language code.
label = "Name"
label = { en = "Name", ja = "名前" }Localizable fields: label, hint, hint_direct, hint_env, sublabel, file_filter, key_label, value_label, the message of constraints/validation rules, and others.
Non-localizable fields: strings such as options, options_from, suffix, id, key, which serve as identifiers or as values stored in the config file. These use the same value regardless of the selected language.
Built-in 16 languages
| Code | Language |
|---|---|
ar | Arabic |
zh | Chinese (Mandarin) |
de | German |
en | English |
fr | French |
hi | Hindi |
it | Italian |
ja | Japanese |
ko | Korean |
nl | Dutch |
pt | Portuguese |
ru | Russian |
es | Spanish |
sv | Swedish |
tr | Turkish |
vi | Vietnamese |
When determining the OS language for lang = "os", the match is on an exact comparison of the primary language subtag (the ja part of "ja-JP"). Language codes not in the list fall back to English. Using [ui_strings], you can supply every string yourself even for language codes without built-in translations.