autodoc_shared_functions
JO Functions > jo.i18n.__() > Syntax
jo.i18n.__(key)
JO Functions > jo.i18n.__() > Parameters
key : string
The key to translate
JO Functions > jo.i18n.__() > Return Value
Type : string
The translated key
JO Functions > jo.i18n.__() > Example
local text = jo.i18n.__("helloWorld")
-- OR --
local text = __("helloWorld")
print(text) -- "Hello World" (or translated text)
JO Functions > jo.i18n.addEntries()
Add multiple entries to the i18n dictionary <br>
The function is exported to allow modification for other resources
JO Functions > jo.i18n.addEntries() > Syntax
jo.i18n.addEntries(entries)
JO Functions > jo.i18n.addEntries() > Parameters
entries : table
The entries to add
JO Functions > jo.i18n.addEntries() > Example
jo.i18n.addEntries({
"buy" = "Buy",
"sell" = "Sell"
})
-- OR --
exports.<scriptName>:addEntries({
"buy" = "Buy",
"sell" = "Sell"
})
JO Functions > jo.i18n.addEntry()
Add a single entry to the i18n dictionary <br>
The function is exported to allow modification for other resources
JO Functions > jo.i18n.addEntry() > Syntax
jo.i18n.addEntry(key, value)
JO Functions > jo.i18n.addEntry() > Parameters
key : string
The key to add
value : string
The value to add
JO Functions > jo.i18n.addEntry() > Example
jo.i18n.addEntry("buyHorse", "Buy a horse")
-- OR --
exports.<scriptName>:addEntry("buyHorse", "Buy a horse")
JO Functions > jo.i18n.findMissingKeys() > Syntax
jo.i18n.findMissingKeys(locale)
JO Functions > jo.i18n.findMissingKeys() > Parameters
locale : string
The locale to check
JO Functions > jo.i18n.findMissingKeys() > Example
jo.i18n.findMissingKeys("es")
-- Expected output: 'Missing key '<key>' for locale '<locale>'
JO Functions > jo.i18n.getEntries() > Syntax
jo.i18n.getEntries()
JO Functions > jo.i18n.getEntries() > Return Value
Type : table
The entries
JO Functions > jo.i18n.getLocale() > Syntax
jo.i18n.getLocale()
JO Functions > jo.i18n.getLocale() > Return Value
Type : string
The current locale
JO Functions > jo.i18n.getLocale() > Example
local locale = jo.i18n.getLocale()
print(locale)
-- Expected output: 'en' (or current locale)
JO Functions > jo.i18n.init() > Syntax
jo.i18n.init()
JO Functions > jo.i18n.init() > Example
jo.i18n.init()
JO Functions > jo.i18n.loadLocale() > Syntax
jo.i18n.loadLocale(locale)
JO Functions > jo.i18n.loadLocale() > Parameters
locale : string
The locale to load
JO Functions > jo.i18n.loadLocale() > Example
jo.i18n.loadLocale("es")
JO Functions > jo.i18n.onLocaleChange()
Register a callback to be called when the locale changes <br>
JO Functions > jo.i18n.onLocaleChange() > Syntax
jo.i18n.onLocaleChange(callback, priority)
JO Functions > jo.i18n.onLocaleChange() > Parameters
callback : function
The callback to register
priority : number
The priority of the callback
JO Functions > jo.i18n.setLocale() > Syntax
jo.i18n.setLocale(locale)
JO Functions > jo.i18n.setLocale() > Parameters
locale : string
The locale to set
JO Functions > jo.i18n.setLocale() > Example
jo.i18n.setLocale("es")