Назад
· 1 мин чтения
Localization
One TOML file per language under strings/, plural forms picked by the locale's rules, a fallback locale, and a missing key that shows itself.
- Dragos Balaur
Strings live in one TOML file per language under strings/. Plural forms
follow the locale's rules, there is a fallback locale, and a missing key
comes back as the key.
- A key maps to a string, or to its plural forms.
{name}in a string is replaced by the argument calledname, and annargument picks the plural form by the locale's rules. - A key missing from the current locale is looked up in the project's fallback locale, one step. Missing from both, the key itself comes back.
strings::set_localeswitches,strings::localeslists the project's locales, andstrings::system_localereads the OS locale.
# strings/en.toml
"menu.play" = "Play"
"menu.items" = { one = "{n} item", other = "{n} items" }
let label = strings::tr("menu.items", #{ n: 3 }); // "3 items"
The strings module is in the
script modules reference.