refactor code to use with intllib tool

This commit is contained in:
codexp
2018-04-02 13:33:36 +02:00
parent 2ab5a7c90a
commit c1ab7277ab
7 changed files with 140 additions and 102 deletions

View File

@ -2,15 +2,9 @@
local modpath = minetest.get_modpath(minetest.get_current_modname())
local worldpath = minetest.get_worldpath()
local mygettext
if rawget(_G, "intllib") then
mygettext = intllib.Getter()
else
function mygettext(s, ...)
local t = { ... }
return (s:gsub("@(%d+)", function(n) return t[tonumber(n)] end))
end
end
-- Intllib
local S, NS = dofile(modpath .. "/intllib.lua")
-- Data tables definitions
unified_inventory = {
@ -40,12 +34,11 @@ unified_inventory = {
default = "craft",
-- intllib
gettext = mygettext,
fgettext = function(...) return minetest.formspec_escape(mygettext(...)) end,
gettext = S,
-- "Lite" mode
lite_mode = minetest.setting_getbool("unified_inventory_lite"),
-- Trash enabled
trash_enabled = (minetest.setting_getbool("unified_inventory_trash") ~= false),