DirkScripts
Docs
Locale
βΉοΈ Shared Module
#locale
Global function. Looks up a translation key and returns the translated string.
lualocal text = locale('fishing.reward_message', playerName, amount)
| Parameter | Type | Required | Description |
|---|---|---|---|
| str | string | yes | Locale key (dot-separated) |
| ... | string | number | no | Format arguments for string interpolation |
If the key doesn't exist it is automatically added as its own translation and saved.
#lib.locale
Loads locale files and builds the translation dictionary. Loads locales/en.json first, then merges the target language on top.
lualib.locale('de') -- load German translations lib.locale() -- uses lib.getLocaleKey() default
| Parameter | Type | Required | Description |
|---|---|---|---|
| key | string | no | Language key (default: lib.getLocaleKey()) |
#lib.getLocales
Returns the full raw locale dictionary.
lualocal dict = lib.getLocales()
#lib.getLocale
Gets a locale string from another resource and adds it to the local dictionary.
lualocal text = lib.getLocale('dirk_fishing', 'cast_prompt')
| Parameter | Type | Required | Description |
|---|---|---|---|
| resource | string | yes | Source resource name |
| key | string | yes | Locale key |
#lib.getLocaleKey
Returns the current language key.
Returns the language code currently selected in the Localization section of dirk_lib's in-game configurator (defaults to en).
lualocal lang = lib.getLocaleKey() -- e.g. 'en'
#lib.setLocale
Sets the locale to a different language. Client only.
lualib.setLocale('fr')
