Add translation support

This commit is contained in:
Jaidyn Ann 2023-12-13 01:58:16 -06:00
parent ebc6e75da9
commit e08b8f37ae
2 changed files with 40 additions and 19 deletions

View File

@ -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
end

19
locale/template.txt Normal file
View File

@ -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=