Skip to content

st.locale — Locale / i18n ​

lua
-- Load locales from locales/en.json (and merge with current language)
st.locale()           -- auto-detects server locale
st.locale('da')       -- explicit language code

-- Translate a key (global function after locale is loaded)
locale('my.key')              -- returns translated string
locale('my.key', arg1, arg2)  -- with format arguments

-- Get all loaded locale strings
st.getLocales()   -- returns { [key] = string }

-- Get a single locale from another resource
local str = st.getLocale('other_resource', 'some.key')

Locale file format (locales/en.json):

json
{
    "cancel_progress": "Cancel",
    "ui": {
        "confirm": "Confirm",
        "cancel": "Cancel"
    }
}

Nested keys are flattened: "ui.confirm", "ui.cancel".