Locale
reads and switches the active locale, and translates a key into the text of that locale
Methods
3 members Access: shared
- Get
() -> string the current locale tag
- Set
(tag: string) -> (boolean, string) switch the locale
Parameters
Name Type Description tag string Language tag such as "en-US". returns (boolean, string) — - Translate
(key: string) -> string translate a key
Parameters
Name Type Description key string Translation key to look up in the active locale. returns string —
Switching the Active Locale
Lifecycle: Shared
Set answers with a status word, and Translate hands back the key itself when the locale has no text for it.
Luau
local ok, status = game.Locale.Set("pt-BR")if not ok then warn("Locale rejected:", status)endprint(string.format("%s: %s", game.Locale.Get(), game.Locale.Translate("ui.play"))) Output: pt-BR: Jogar