From 62bc13078f4e93993ebf121cc9c74bc31a6e5d90 Mon Sep 17 00:00:00 2001 From: Louis Royer <4259825-lroyer@users.noreply.gitlab.com> Date: Tue, 18 Feb 2020 17:34:52 +0000 Subject: Add translation support - Created `locale/template.txt` - Fixed some typos - Replace some `print("[pipeworks]"..` with `pipeworks.logger()` - Removed "You hacker, you" from descriptions --- autocrafter.lua | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'autocrafter.lua') diff --git a/autocrafter.lua b/autocrafter.lua index ebde77c..db23a14 100644 --- a/autocrafter.lua +++ b/autocrafter.lua @@ -1,3 +1,4 @@ +local S = minetest.get_translator("pipeworks") local autocrafterCache = {} -- caches some recipe data to avoid to call the slow function minetest.get_craft_result() every second local craft_time = 1 @@ -16,7 +17,7 @@ end local function get_item_info(stack) local name = stack:get_name() local def = minetest.registered_items[name] - local description = def and def.description or "Unknown item" + local description = def and def.description or S("Unknown item") return description, name end @@ -68,7 +69,7 @@ local function run_autocrafter(pos, elapsed) local output_item = craft.output.item -- only use crafts that have an actual result if output_item:is_empty() then - meta:set_string("infotext", "unconfigured Autocrafter: unknown recipe") + meta:set_string("infotext", S("unconfigured Autocrafter: unknown recipe")) return false end @@ -101,7 +102,7 @@ local function after_recipe_change(pos, inventory) if inventory:is_empty("recipe") then minetest.get_node_timer(pos):stop() autocrafterCache[minetest.hash_node_position(pos)] = nil - meta:set_string("infotext", "unconfigured Autocrafter") + meta:set_string("infotext", S("unconfigured Autocrafter")) inventory:set_stack("output", 1, "") return end @@ -126,7 +127,7 @@ local function after_recipe_change(pos, inventory) craft = craft or get_craft(pos, inventory, hash) local output_item = craft.output.item local description, name = get_item_info(output_item) - meta:set_string("infotext", string.format("'%s' Autocrafter (%s)", description, name)) + meta:set_string("infotext", S("'@1' Autocrafter (@2)", description, name)) inventory:set_stack("output", 1, output_item) after_inventory_change(pos) @@ -190,8 +191,8 @@ local function update_meta(meta, enabled) "listring[context;dst]" .. "listring[current_player;main]" if minetest.get_modpath("digilines") then - fs = fs.."field[1,3.5;4,1;channel;Channel;${channel}]" - fs = fs.."button_exit[5,3.2;2,1;save;Save]" + fs = fs.."field[1,3.5;4,1;channel;"..S("Channel")..";${channel}]" + fs = fs.."button_exit[5,3.2;2,1;save;"..S("Save").."]" end meta:set_string("formspec",fs) @@ -200,13 +201,13 @@ local function update_meta(meta, enabled) -- this might be more written code, but actually executes less local output = meta:get_inventory():get_stack("output", 1) if output:is_empty() then -- doesn't matter if paused or not - meta:set_string("infotext", "unconfigured Autocrafter") + meta:set_string("infotext", S("unconfigured Autocrafter")) return false end local description, name = get_item_info(output) - local infotext = enabled and string.format("'%s' Autocrafter (%s)", description, name) - or string.format("paused '%s' Autocrafter", description) + local infotext = enabled and S("'@1' Autocrafter (@2)", description, name) + or S("paused '@1' Autocrafter", description) meta:set_string("infotext", infotext) return enabled @@ -226,7 +227,7 @@ local function upgrade_autocrafter(pos, meta) update_meta(meta, true) if meta:get_string("virtual_items") == "1" then -- we are version 2 - -- we allready dropped stuff, so lets remove the metadatasetting (we are not being called again for this node) + -- we already dropped stuff, so lets remove the metadatasetting (we are not being called again for this node) meta:set_string("virtual_items", "") else -- we are version 1 local recipe = inv:get_list("recipe") @@ -248,7 +249,7 @@ local function upgrade_autocrafter(pos, meta) end minetest.register_node("pipeworks:autocrafter", { - description = "Autocrafter", + description = S("Autocrafter"), drawtype = "normal", tiles = {"pipeworks_autocrafter.png"}, groups = {snappy = 3, tubedevice = 1, tubedevice_receiver = 1}, -- cgit v1.2.3