zephyr.locale

Look up translations from the module and framework catalogs, honoring the configured preferred and fallback languages.

4 functions

language

zephyr.locale.language()

Return the configured preferred language tag.

Returns

string

The preferred language, e.g. en-US.

fallback_language

zephyr.locale.fallback_language()

Return the configured fallback language tag.

Returns

string

The fallback language, e.g. en-US.

t

zephyr.locale.t(key, vars?)

Translate a key and interpolate optional placeholders.

Lookup order: module catalog (preferred, then fallback, then en-US), framework catalog (preferred, then fallback, then en-US), then the key itself. Placeholders use {name} syntax.

Parameters

keystring

Translation key to look up.

varstableoptional

Placeholder values to interpolate into the string.

Returns

string

The translated string, or the key itself when no catalog matches.

Example

lua
local label = zephyr.locale.t("example.loaded", { id = zephyr.package.id })

has

zephyr.locale.has(key)

Check whether a translation key exists.

Parameters

keystring

Translation key to check.

Returns

boolean

true if the module or framework catalog contains key.