From 75a0e6a31880bb3b0412288e7add99257805e8d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Mart=C3=ADnez?= Date: Sat, 8 Oct 2016 06:07:41 -0300 Subject: Bags: Code cleanup and per-bag trash slot. * Turn page creation into a loop. * Add per-bag trash slot. * Changed i18n to allow replacements. --- init.lua | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'init.lua') diff --git a/init.lua b/init.lua index e24fff2..f92d278 100644 --- a/init.lua +++ b/init.lua @@ -2,7 +2,15 @@ local modpath = minetest.get_modpath(minetest.get_current_modname()) local worldpath = minetest.get_worldpath() -local mygettext = rawget(_G, "intllib") and intllib.Getter() or function(s) return s end +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 -- Data tables definitions unified_inventory = { @@ -33,7 +41,7 @@ unified_inventory = { -- intllib gettext = mygettext, - fgettext = function(s) return minetest.formspec_escape(mygettext(s)) end, + fgettext = function(...) return minetest.formspec_escape(mygettext(...)) end, -- "Lite" mode lite_mode = minetest.setting_getbool("unified_inventory_lite"), -- cgit v1.2.3