summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiego Martínez <kaeza@users.sf.net>2013-03-05 08:58:31 -0200
committerDiego Martínez <kaeza@users.sf.net>2013-03-05 08:58:31 -0200
commitb6c110168f104bbb4bbebb1f0bee8eba6aa966cd (patch)
tree775daedd4c781584d2a4321d40cc98e09c658764
parent11b9e0596c0567c5b6737394f9f6a8aaac560262 (diff)
Various fixes
-rw-r--r--intllib.lua27
1 files changed, 17 insertions, 10 deletions
diff --git a/intllib.lua b/intllib.lua
index a59d5b4..18bd0b2 100644
--- a/intllib.lua
+++ b/intllib.lua
@@ -65,16 +65,19 @@ local function do_load_strings ( f )
return msgstr;
end
-function intllib.load_strings ( modname )
- local f, e = io.open(minetest.get_modpath(modname).."/locale/"..LANG..".txt");
- if (f) then
- local strings;
- strings = do_load_strings(f);
- f:close();
- return strings;
- else
- return nil, "Could not load '"..LANG.."' texts: "..e;
+function load_strings ( modname, lang )
+ lang = lang or LANG;
+ local f, e = io.open(minetest.get_modpath(modname).."/locale/"..lang..".txt");
+ if (not f) then
+ f, e = io.open(minetest.get_modpath("intllib").."/locale/"..modname.."/"..lang..".txt");
+ if (not f) then
+ return nil, "Could not load '"..LANG.."' texts: "..e;
+ end
end
+ local strings;
+ strings = do_load_strings(f);
+ f:close();
+ return strings;
end
local getters = { };
@@ -82,10 +85,14 @@ local getters = { };
function intllib.Getter ( modname )
if (not modname) then modname = minetest.get_current_modname(); end
if (not getters[modname]) then
- local msgstr = intllib.load_strings(modname) or { };
+ local msgstr = load_strings(modname, lang) or { };
getters[modname] = function ( s )
return msgstr[repr(s)] or s;
end;
end
return getters[modname];
end
+
+function intllib.get_current_language ( )
+ return LANG;
+end