From 21532968d4d22701486b3d86dce95de3c591a73e Mon Sep 17 00:00:00 2001 From: "Y. Wang" Date: Fri, 6 Oct 2023 23:24:45 +0200 Subject: Setup more strings for localization --- advtrains_luaautomation/active_common.lua | 20 ++++++++++---------- advtrains_luaautomation/atc_rail.lua | 2 +- advtrains_luaautomation/init.lua | 6 +++--- advtrains_luaautomation/mesecon_controller.lua | 3 ++- advtrains_luaautomation/operation_panel.lua | 3 ++- advtrains_luaautomation/pcnaming.lua | 8 +++++--- 6 files changed, 23 insertions(+), 19 deletions(-) (limited to 'advtrains_luaautomation') diff --git a/advtrains_luaautomation/active_common.lua b/advtrains_luaautomation/active_common.lua index 50fb2bc..bf3e090 100644 --- a/advtrains_luaautomation/active_common.lua +++ b/advtrains_luaautomation/active_common.lua @@ -1,4 +1,4 @@ - +local S = atltrans local ac = {nodes={}} @@ -14,7 +14,7 @@ end function ac.after_place_node(pos, player) local meta=minetest.get_meta(pos) meta:set_string("formspec", ac.getform(pos, meta)) - meta:set_string("infotext", "LuaATC component, unconfigured.") + meta:set_string("infotext", S("Unconfigured LuaATC component")) local ph=minetest.pos_to_string(pos) --just get first available key! for en,_ in pairs(atlatc.envs) do @@ -43,11 +43,11 @@ function ac.getform(pos, meta_p) end local form = "size["..atlatc.CODE_FORM_SIZE.."]" .."style[code;font=mono]" - .."label[0,-0.1;Environment]" + .."label[0,-0.1;"..S("LuaATC Environment").."]" .."dropdown[0,0.3;3;env;"..table.concat(envs_asvalues, ",")..";"..sel.."]" - .."button[5,0.2;2,1;save;Save]" - .."button[7,0.2;3,1;cle;Clear Local Env.]" - .."textarea[0.3,1.5;"..atlatc.CODE_FORM_SIZE..";code;Code;"..minetest.formspec_escape(code).."]" + .."button[5,0.2;2,1;save;"..S("Save").."]" + .."button[7,0.2;3,1;cle;"..S("Clear Local Environment").."]" + .."textarea[0.3,1.5;"..atlatc.CODE_FORM_SIZE..";code;"..S("Code")..";"..minetest.formspec_escape(code).."]" .."label["..atlatc.CODE_FORM_ERRLABELPOS..";"..err.."]" return form end @@ -61,7 +61,7 @@ end function ac.on_receive_fields(pos, formname, fields, player) if not minetest.check_player_privs(player:get_player_name(), {atlatc=true}) then - minetest.chat_send_player(player:get_player_name(), "Missing privilege: atlatc - Operation cancelled!") + minetest.chat_send_player(player:get_player_name(), S("You are not allowed to modify this LuaATC component without the @1 privilege.", "atlatc")) return end @@ -91,9 +91,9 @@ function ac.on_receive_fields(pos, formname, fields, player) meta:set_string("formspec", ac.getform(pos, meta)) if nodetbl.env then - meta:set_string("infotext", "LuaATC component, assigned to environment '"..nodetbl.env.."'") + meta:set_string("infotext", S("LuaATC component assigned to environment '@1'", nodetbl.env)) else - meta:set_string("infotext", "LuaATC component, invalid enviroment set!") + meta:set_string("infotext", S("LuaATC component assigned to an invalid environment")) end end @@ -168,7 +168,7 @@ function ac.run_in_env(pos, evtdata, customfct_p, ignore_no_code) atlatc.active.nodes[ph].err=dataout env:log("error", "LuaATC component at",ph,": LUA Error:",dataout) if meta then - meta:set_string("infotext", "LuaATC component, ERROR:"..dataout) + meta:set_string("infotext", S("LuaATC component with error: @1", dataout)) end --TODO temporary --if customfct.atc_id then diff --git a/advtrains_luaautomation/atc_rail.lua b/advtrains_luaautomation/atc_rail.lua index aac11f0..f069600 100755 --- a/advtrains_luaautomation/atc_rail.lua +++ b/advtrains_luaautomation/atc_rail.lua @@ -219,7 +219,7 @@ advtrains.register_tracks("default", { models_prefix="advtrains_dtrack", models_suffix=".b3d", shared_texture="advtrains_dtrack_shared_atc.png", - description=atltrans("LuaATC Rail"), + description=atltrans("LuaATC Track"), formats={}, get_additional_definiton = function(def, preset, suffix, rotation) return { diff --git a/advtrains_luaautomation/init.lua b/advtrains_luaautomation/init.lua index c51aa71..603d240 100644 --- a/advtrains_luaautomation/init.lua +++ b/advtrains_luaautomation/init.lua @@ -2,15 +2,15 @@ -- Lua automation features for advtrains -- Uses global table 'atlatc' (AdvTrains_LuaATC) ---TODO: re-add localization (if merging localization, discard this hunk please) -atltrans = function(s,a,...)a={a,...}return s:gsub("@(%d+)",function(n)return a[tonumber(n)]end)end +atltrans = attrans +local S = atltrans --Privilege --Only trusted players should be enabled to build stuff which can break the server. atlatc = { envs = {}} -minetest.register_privilege("atlatc", { description = "Player can place and modify LUA ATC components. Grant with care! Allows to execute bad LUA code.", give_to_singleplayer = false, default= false }) +minetest.register_privilege("atlatc", { description = S("Can place and modify LuaATC components, including execute potentially harmful Lua code"), give_to_singleplayer = false, default= false }) --Size of code input forms in X,Y notation. Must be at least 10x10 atlatc.CODE_FORM_SIZE = "15,12" diff --git a/advtrains_luaautomation/mesecon_controller.lua b/advtrains_luaautomation/mesecon_controller.lua index bffff84..6981839 100644 --- a/advtrains_luaautomation/mesecon_controller.lua +++ b/advtrains_luaautomation/mesecon_controller.lua @@ -6,6 +6,7 @@ -- From Mesecons mod https://mesecons.net/ -- (c) Jeija and Contributors +local S = atltrans local BASENAME = "advtrains_luaautomation:mesecon_controller" local rules = { @@ -207,7 +208,7 @@ for d = 0, 1 do } minetest.register_node(node_name, { - description = "LuaATC Mesecon Controller", + description = S("LuaATC Mesecon Controller"), drawtype = "nodebox", tiles = { top, diff --git a/advtrains_luaautomation/operation_panel.lua b/advtrains_luaautomation/operation_panel.lua index c118ff3..8e12651 100755 --- a/advtrains_luaautomation/operation_panel.lua +++ b/advtrains_luaautomation/operation_panel.lua @@ -1,3 +1,4 @@ +local S = atltrans local function on_punch(pos,node,player) atlatc.interrupt.add(0, pos, {type="punch", punch=true, name=player:get_player_name()}) @@ -7,7 +8,7 @@ end minetest.register_node("advtrains_luaautomation:oppanel", { drawtype = "normal", tiles={"atlatc_oppanel.png"}, - description = "LuaATC operation panel", + description = S("LuaATC Operation Panel"), groups = { cracky = 1, save_in_at_nodedb=1, diff --git a/advtrains_luaautomation/pcnaming.lua b/advtrains_luaautomation/pcnaming.lua index 71f4d9a..60983a6 100644 --- a/advtrains_luaautomation/pcnaming.lua +++ b/advtrains_luaautomation/pcnaming.lua @@ -2,6 +2,8 @@ --a.k.a Passive component naming --Allows to assign names to passive components, so they can be called like: --setstate("iamasignal", "green") +local S = atltrans + atlatc.pcnaming={name_map={}} function atlatc.pcnaming.load(stuff) if type(stuff)=="table" then @@ -23,7 +25,7 @@ function atlatc.pcnaming.resolve_pos(pos, func_name) end minetest.register_craftitem("advtrains_luaautomation:pcnaming",{ - description = attrans("Passive Component Naming Tool\n\nRight-click to name a passive component."), + description = S("Passive Component Naming Tool\n\nRight-click to name a passive component."), groups = {cracky=1}, -- key=name, value=rating; rating=1..3. inventory_image = "atlatc_pcnaming.png", wield_image = "atlatc_pcnaming.png", @@ -34,7 +36,7 @@ minetest.register_craftitem("advtrains_luaautomation:pcnaming",{ return end if not minetest.check_player_privs(pname, {atlatc=true}) then - minetest.chat_send_player(pname, "Missing privilege: atlatc") + minetest.chat_send_player(pname, S("You are not allowed to name LuaATC passive components without the @1 privilege.", "atlatc")) return end if pointed_thing.type=="node" then @@ -57,7 +59,7 @@ minetest.register_craftitem("advtrains_luaautomation:pcnaming",{ pn=name end end - minetest.show_formspec(pname, "atlatc_naming_"..minetest.pos_to_string(pos), "field[pn;Set name of component (empty to clear);"..minetest.formspec_escape(pn).."]") + minetest.show_formspec(pname, "atlatc_naming_"..minetest.pos_to_string(pos), "field[pn;"..S("Set name of component (empty to clear)")..";"..minetest.formspec_escape(pn).."]") end end end, -- cgit v1.2.3