1 2local lang 3local lang_en 4 5local game_type = config_get_game_type() 6local lang_selected = config_get_language() 7 8function lang_init(lang_type) 9 if lang_type ~= "intro" then 10 lang_type = "game" 11 end 12 13 lang_en = nuvie_load(string.lower(game_type).."/lang/en/"..lang_type..".lua") 14 15 if lang_en == nil then 16 lang_en = {} 17 else 18 lang_en = lang_en() 19 end 20 21 if lang_selected ~= "en" then 22 lang = nuvie_load(string.lower(game_type).."/lang/"..lang_selected.."/"..lang_type..".lua") 23 if lang == nil then 24 lang = lang_en 25 else 26 lang = lang() 27 end 28 else 29 lang = lang_en 30 end 31end 32 33function i18n(code) 34 local str = lang[code] 35 if str == nil then 36 str = lang_en[code] 37 end 38 if str == nil then 39 str = code 40 end 41 return str; 42end 43 44function i18nf(code, ...) 45 return string.format(i18n(code), ...) 46end 47 48function printnl(code) 49 print("\n"..i18n(code)) 50end 51 52function printl(code) 53 print(i18n(code)) 54end 55 56function printfl(code, ...) 57 print(i18nf(code, ...)) 58end 59