From e08b8f37aef14b1e9f89fb4cbd518e060e2bdafc Mon Sep 17 00:00:00 2001 From: Jaidyn Ann <10477760+JadedCtrl@users.noreply.github.com> Date: Wed, 13 Dec 2023 01:58:16 -0600 Subject: [PATCH] Add translation support --- init.lua | 40 +++++++++++++++++++++------------------- locale/template.txt | 19 +++++++++++++++++++ 2 files changed, 40 insertions(+), 19 deletions(-) create mode 100644 locale/template.txt diff --git a/init.lua b/init.lua index c925325..7488e99 100644 --- a/init.lua +++ b/init.lua @@ -1,3 +1,5 @@ +local S = minetest.get_translator("kotatsu_table") + kotatsu_table = {} kotatsu_table.toggle_sitting = function(npos, _, player) local meta = minetest.get_meta(npos) @@ -89,10 +91,10 @@ kotatsu_table.register_table = function(name, desc, base, tiles, top, top_tiles, top_tiles = top_tiles or (minetest.registered_nodes[top] or {tiles={"default_wood.png"}}).tiles inv_image = inv_image or "(kotatsu_base.png^[mask:"..tiles[1]..")^(kotatsu_top.png^[mask:"..top_tiles[1]..")" local kotatsu = name or ("kotatsu_table:table_"..string.gsub(base, ":", "_")) - desc = (desc or (minetest.registered_nodes[base] or {description="Terribly Programmed"}).description or "Very Terribly Programmed").." Kotatsu Table" + desc = desc or S("@1 Kotatsu Table", (minetest.registered_nodes[base] or {description="Terribly Programmed"}).description or "Very Terribly Programmed") minetest.register_node(kotatsu.."_side", { - description = desc.." Blanket Side (you hacker, you)", + description = S("@1 (Blanket Side; you hacker, you)", desc), paramtype = "light", walkable = false, drawtype = "nodebox", @@ -108,7 +110,7 @@ kotatsu_table.register_table = function(name, desc, base, tiles, top, top_tiles, }) minetest.register_node(kotatsu.."_corner", { - description = desc.." Blanket Corner (you hacker, you)", + description = S("@1 (Blanket Corner; you hacker, you)", desc), paramtype = "light", walkable = false, drawtype = "nodebox", @@ -170,24 +172,24 @@ kotatsu_table.register_table = function(name, desc, base, tiles, top, top_tiles, }) end kotatsu_table.wool_dyes = { - {"white", "White"}, - {"grey", "Grey"}, - {"black", "Black"}, - {"red", "Red"}, - {"yellow", "Yellow"}, - {"green", "Green"}, - {"cyan", "Cyan"}, - {"blue", "Blue"}, - {"magenta", "Magenta"}, - {"orange", "Orange"}, - {"violet", "Violet"}, - {"brown", "Brown"}, - {"pink", "Pink"}, - {"dark_grey", "Dark Grey"}, - {"dark_green", "Dark Green"}, + {"white", S("White Kotatsu Table")}, + {"grey", S("Grey Kotatsu Table")}, + {"black", S("Black Kotatsu Table")}, + {"red", S("Red Kotatsu Table")}, + {"yellow", S("Yellow Kotatsu Table")}, + {"green", S("Green Kotatsu Table")}, + {"cyan", S("Cyan Kotatsu Table")}, + {"blue", S("Blue Kotatsu Table")}, + {"magenta", S("Magenta Kotatsu Table")}, + {"orange", S("Orange Kotatsu Table")}, + {"violet", S("Violet Kotatsu Table")}, + {"brown", S("Brown Kotatsu Table")}, + {"pink", S("Pink Kotatsu Table")}, + {"dark_grey", S("Dark Grey Kotatsu Table")}, + {"dark_green", S("Dark Green Kotatsu Table")}, } for _,d in pairs(kotatsu_table.wool_dyes) do kotatsu_table.register_table(nil, d[2], "wool:"..d[1]) -end \ No newline at end of file +end diff --git a/locale/template.txt b/locale/template.txt new file mode 100644 index 0000000..4e78ce4 --- /dev/null +++ b/locale/template.txt @@ -0,0 +1,19 @@ +# textdomain: kotatsu_table +@1 Kotatsu Table= +@1 (Blanket Side; you hacker, you)= +@1 (Blanket Corner; you hacker, you)= +White Kotatsu Table= +Grey Kotatsu Table= +Black Kotatsu Table= +Red Kotatsu Table= +Yellow Kotatsu Table= +Green Kotatsu Table= +Cyan Kotatsu Table= +Blue Kotatsu Table= +Magenta Kotatsu Table= +Orange Kotatsu Table= +Violet Kotatsu Table= +Brown Kotatsu Table= +Pink Kotatsu Table= +Dark Grey Kotatsu Table= +Dark Green Kotatsu Table=