mirror of
https://github.com/minetest-mods/intllib.git
synced 2025-01-24 17:00:18 +01:00
Various fixes
This commit is contained in:
parent
11b9e0596c
commit
b6c110168f
27
intllib.lua
27
intllib.lua
@ -65,16 +65,19 @@ local function do_load_strings ( f )
|
|||||||
return msgstr;
|
return msgstr;
|
||||||
end
|
end
|
||||||
|
|
||||||
function intllib.load_strings ( modname )
|
function load_strings ( modname, lang )
|
||||||
local f, e = io.open(minetest.get_modpath(modname).."/locale/"..LANG..".txt");
|
lang = lang or LANG;
|
||||||
if (f) then
|
local f, e = io.open(minetest.get_modpath(modname).."/locale/"..lang..".txt");
|
||||||
local strings;
|
if (not f) then
|
||||||
strings = do_load_strings(f);
|
f, e = io.open(minetest.get_modpath("intllib").."/locale/"..modname.."/"..lang..".txt");
|
||||||
f:close();
|
if (not f) then
|
||||||
return strings;
|
return nil, "Could not load '"..LANG.."' texts: "..e;
|
||||||
else
|
end
|
||||||
return nil, "Could not load '"..LANG.."' texts: "..e;
|
|
||||||
end
|
end
|
||||||
|
local strings;
|
||||||
|
strings = do_load_strings(f);
|
||||||
|
f:close();
|
||||||
|
return strings;
|
||||||
end
|
end
|
||||||
|
|
||||||
local getters = { };
|
local getters = { };
|
||||||
@ -82,10 +85,14 @@ local getters = { };
|
|||||||
function intllib.Getter ( modname )
|
function intllib.Getter ( modname )
|
||||||
if (not modname) then modname = minetest.get_current_modname(); end
|
if (not modname) then modname = minetest.get_current_modname(); end
|
||||||
if (not getters[modname]) then
|
if (not getters[modname]) then
|
||||||
local msgstr = intllib.load_strings(modname) or { };
|
local msgstr = load_strings(modname, lang) or { };
|
||||||
getters[modname] = function ( s )
|
getters[modname] = function ( s )
|
||||||
return msgstr[repr(s)] or s;
|
return msgstr[repr(s)] or s;
|
||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
return getters[modname];
|
return getters[modname];
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function intllib.get_current_language ( )
|
||||||
|
return LANG;
|
||||||
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user