summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShadowNinja <shadowninja@minetest.net>2015-02-03 17:21:35 -0500
committerShadowNinja <shadowninja@minetest.net>2015-02-03 17:21:35 -0500
commitc497c7b10cbf9b119ee66021c8224d8b25c598a8 (patch)
tree46a71fd89879551ab6e62eba43738000c9cb6033
parent4404c4071cddfd7c30b2420be54d184067797482 (diff)
Fix insertions with missing translations
-rw-r--r--init.lua22
1 files changed, 8 insertions, 14 deletions
diff --git a/init.lua b/init.lua
index 3712bea..cb30b8c 100644
--- a/init.lua
+++ b/init.lua
@@ -17,25 +17,23 @@ intllib.getters = intllib.getters or {}
intllib.strings = {}
-local function noop_getter(s)
- return s
-end
-
-
local INS_CHAR = intllib.INSERTION_CHAR
local insertion_pattern = "("..INS_CHAR.."?)"..INS_CHAR.."(%(?)(%d+)(%)?)"
-local function make_getter(strs)
+local function make_getter(msgstrs)
return function(s, ...)
- local str = strs[s]
+ local str
+ if strs then
+ str = msgstrs[s]
+ end
if not str or str == "" then
- return s
+ str = s
end
if select("#", ...) == 0 then
return str
end
local args = {...}
- local str = str:gsub(insertion_pattern, function(escape, open, num, close)
+ str = str:gsub(insertion_pattern, function(escape, open, num, close)
if escape == "" then
local replacement = tostring(args[tonumber(num)])
if open == "" then
@@ -55,11 +53,7 @@ function intllib.Getter(modname)
modname = modname or minetest.get_current_modname()
if not intllib.getters[modname] then
local msgstr = intllib.get_strings(modname)
- if msgstr then
- intllib.getters[modname] = make_getter(msgstr)
- else
- intllib.getters[modname] = noop_getter
- end
+ intllib.getters[modname] = make_getter(msgstr)
end
return intllib.getters[modname]
end