diff options
author | ShadowNinja <shadowninja@minetest.net> | 2014-02-12 17:27:09 -0500 |
---|---|---|
committer | ShadowNinja <shadowninja@minetest.net> | 2014-02-12 17:27:09 -0500 |
commit | 3a3da7359c1acc46bd6aca86c5cb351eb15e0d76 (patch) | |
tree | 073ebd71542dda8c47a09ac639cc74eddcf2621a | |
parent | 4be14170e7d050dee610424a91a465633da71944 (diff) |
Add get_strings()
-rw-r--r-- | init.lua | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -16,6 +16,8 @@ LANG = LANG:sub(1, 2) -- Support the old multi-load method intllib.getters = intllib.getters or {} +intllib.strings = {} + local function noop_getter(s) return s end @@ -27,6 +29,7 @@ function intllib.Getter(modname) if modpath then local filename = modpath.."/locale/"..LANG..".txt" local msgstr = intllib.load_strings(filename) + intllib.strings[modname] = msgstr or false if msgstr then intllib.getters[modname] = function (s) if msgstr[s] and msgstr[s] ~= "" then @@ -42,3 +45,14 @@ function intllib.Getter(modname) return intllib.getters[modname] end +function intllib.get_strings(modname) + modname = modname or minetest.get_current_modname() + local msgstr = intllib.strings[modname] + if msgstr == nil then + local modpath = minetest.get_modpath(modname) + msgstr = intllib.load_strings(modpath.."/locale/"..LANG..".txt") + intllib.strings[modname] = msgstr + end + return msgstr or nil +end + |