Locales
Shiva has a built-in localisation system. All user-facing strings live in locale files and are never hardcoded.
Locale File Structure
lua
-- shared/locales/en.lua
return {
['fishing.cast'] = 'You cast your line...',
['fishing.caught'] = 'You caught a {fish}!',
['fishing.missed'] = 'The fish got away...',
['fishing.no_rod'] = 'You need a fishing rod.',
['fishing.not_near'] = 'You are not near a fishing spot.',
}Using Locales
lua
local Lang = require('shiva-fw.lang')
-- Simple lookup
local msg = Lang.t('fishing.cast') -- 'You cast your line...'
-- With interpolation
local msg = Lang.t('fishing.caught', { fish = 'Bass' }) -- 'You caught a Bass!'Adding a Language
Create a new file in shared/locales/:
lua
-- shared/locales/es.lua
return {
['fishing.cast'] = 'Lanzaste tu línea...',
['fishing.caught'] = '¡Atrapaste un {fish}!',
['fishing.missed'] = 'El pez escapó...',
}The active locale is controlled by Shiva.locale in shiva.config.lua.
Overriding Strings
Server owners can override any string without editing the module. Create resources/my-overrides/locales/my-fishing/en.lua:
lua
return {
['fishing.caught'] = 'Nice catch! You got a {fish}!',
}Locale Keys Convention
Use dot-separated namespaces: module.context.action
fishing.cast
fishing.caught
fishing.error.no_rod
ui.menu.title
ui.button.confirm