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
The preferred language, e.g. en-US.
fallback_language
zephyr.locale.fallback_language()Return the configured fallback language tag.
Returns
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
keystringTranslation key to look up.
varstableoptionalPlaceholder values to interpolate into the string.
Returns
The translated string, or the key itself when no catalog matches.
Example
local label = zephyr.locale.t("example.loaded", { id = zephyr.package.id })has
zephyr.locale.has(key)Check whether a translation key exists.
Parameters
keystringTranslation key to check.
Returns
true if the module or framework catalog contains key.