support multi-language games.
- Precondition
- require
i18n
The format of language must be aa-AA
, respectively ISO 639 and ISO 3166, This module is based on the system language, but can also store the last saved language.
- Example
local function i18n(std, game)
return {
['pt-BR'] = {
['hello world'] = 'ola mundo'
},
['es-ES'] = {
['hello world'] = 'hola mundo'
}
}
end
local function draw(std, game)
std.draw.clear(std.color.black)
std.draw.color(std.color.white)
std.draw.text(8, 8, 'hello world')
end
local P = {
meta = {
},
config = {
require='i18n'
},
callbacks = {
i18n=i18n,
draw=draw
}
}
return P
local function title(window_name)
◆ back()
- Example
if game.state == game.menu_lang and std.key.press.left then
std.i18n.back()
end
◆ get_language()
local function get_language |
( |
| ) |
|
- Example
local language = std.i18n.get_language()
std.draw.text(8, 8, language)
◆ get_text()
local function get_text |
( |
old_text | | ) |
|
- Example
local some_text = std.i18n.get_text('some-text')
std.draw.text(8, 8, rot32(some_text))
◆ next()
- Example
if game.state == game.menu_lang then
std.i18n.next(std.key.axis.y)
end
◆ set_language()
local function set_language |
( |
l | | ) |
|
- Example
std.i18n.set_langauge('en-US')