1
0
mirror of https://github.com/minetest-mods/intllib.git synced 2024-11-10 20:30:46 +01:00

Logging fixes.

* Remove use of `rawget`.
* Fix code trying to concat a nil value in some cases.
* Prefix warnings with mod name.
This commit is contained in:
Diego Martínez 2017-01-27 10:18:28 -03:00
parent b98f01b2da
commit 8eae4eec38

View File

@ -136,7 +136,7 @@ local function detect_languages()
local v local v
v = rawget(_G, "minetest") and minetest.setting_get("language") v = minetest.setting_get("language")
if v and v~="" then if v and v~="" then
addlang(v) addlang(v)
end end
@ -157,11 +157,7 @@ local function detect_languages()
end end
local function warn(msg) local function warn(msg)
if rawget(_G, "minetest") then minetest.log("warning", "[intllib] "..msg)
minetest.log("warning", msg)
else
io.stderr:write("WARNING: ", msg, "\n")
end
end end
-- hax! -- hax!
@ -224,7 +220,7 @@ local function load_catalog(filename)
local f, data, err local f, data, err
local function bail(msg) local function bail(msg)
warn(msg..(err and ": ")..(err or "")) warn(msg..(err and ": " or "")..(err or ""))
return nil return nil
end end