Gly Game Engine 0.0.7
Game engine in lua
Loading...
Searching...
No Matches
I18n

Internationalization. More...

Collaboration diagram for I18n:

Functions

local function get_text (old_text)
 
local function get_language ()
 
local function set_language (l)
 
local function back_language ()
 
local function next_language ()
 

Detailed Description

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 = {
title='Hello'
},
config = {
require='i18n'
},
callbacks = {
i18n=i18n,
draw=draw
}
}
return P

Function Documentation

◆ back_language()

local function back_language ( )
Example
if game.state == game.menu_lang and std.key.press.left then
std.i18n.back_language()
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_language()

local function next_language ( )
Example
if game.state == game.menu_lang and std.key.press.right then
std.i18n.next_language()
end

◆ set_language()

local function set_language ( l )
Example
std.i18n.set_langauge('en-US')