add translation support (thanks Niklp)

This commit is contained in:
tenplus1 2023-09-03 11:07:28 +01:00
parent 720adef1d0
commit b05fb6087a
3 changed files with 78 additions and 34 deletions

@ -1,17 +1,17 @@
-- 5.x translation -- translation support
S = minetest.get_translator("bakedclay") local S = minetest.get_translator("bakedclay")
local flowers = { local flowers = {
{"delphinium", "Blue Delphinium", {"delphinium", S("Blue Delphinium"),
{-0.15, -0.5, -0.15, 0.15, 0.3, 0.15}, {color_cyan = 1}}, {-0.15, -0.5, -0.15, 0.15, 0.3, 0.15}, {color_cyan = 1}},
{"thistle", "Thistle", {"thistle", S("Thistle"),
{-0.15, -0.5, -0.15, 0.15, 0.2, 0.15}, {color_magenta = 1}}, {-0.15, -0.5, -0.15, 0.15, 0.2, 0.15}, {color_magenta = 1}},
{"lazarus", "Lazarus Bell", {"lazarus", S("Lazarus Bell"),
{-0.15, -0.5, -0.15, 0.15, 0.2, 0.15}, {color_pink = 1}}, {-0.15, -0.5, -0.15, 0.15, 0.2, 0.15}, {color_pink = 1}},
{"mannagrass", "Reed Mannagrass", {"mannagrass", S("Reed Mannagrass"),
{-0.15, -0.5, -0.15, 0.15, 0.2, 0.15}, {color_dark_green = 1}} {-0.15, -0.5, -0.15, 0.15, 0.2, 0.15}, {color_dark_green = 1}}
} }
@ -25,7 +25,7 @@ local function add_simple_flower(name, desc, box, f_groups)
f_groups.attached_node = 1 f_groups.attached_node = 1
minetest.register_node("bakedclay:" .. name, { minetest.register_node("bakedclay:" .. name, {
description = S(desc), description = desc,
drawtype = "plantlike", drawtype = "plantlike",
waving = 1, waving = 1,
tiles = {"baked_clay_" .. name .. ".png"}, tiles = {"baked_clay_" .. name .. ".png"},
@ -35,7 +35,6 @@ local function add_simple_flower(name, desc, box, f_groups)
paramtype = "light", paramtype = "light",
walkable = false, walkable = false,
buildable_to = true, buildable_to = true,
-- stack_max = 99,
groups = f_groups, groups = f_groups,
sounds = default.node_sound_leaves_defaults(), sounds = default.node_sound_leaves_defaults(),
selection_box = {type = "fixed", fixed = box} selection_box = {type = "fixed", fixed = box}

@ -1,27 +1,31 @@
-- 5.x translation
S = minetest.get_translator("bakedclay") -- translation support
local S = minetest.get_translator("bakedclay")
-- list of clay colours -- list of clay colours
local clay = { local clay = {
{"natural", "Natural"}, {"natural", S("Natural")},
{"white", "White"}, {"white", S("White")},
{"grey", "Grey"}, {"grey", S("Grey")},
{"black", "Black"}, {"black", S("Black")},
{"red", "Red"}, {"red", S("Red")},
{"yellow", "Yellow"}, {"yellow", S("Yellow")},
{"green", "Green"}, {"green", S("Green")},
{"cyan", "Cyan"}, {"cyan", S("Cyan")},
{"blue", "Blue"}, {"blue", S("Blue")},
{"magenta", "Magenta"}, {"magenta", S("Magenta")},
{"orange", "Orange"}, {"orange", S("Orange")},
{"violet", "Violet"}, {"violet", S("Violet")},
{"brown", "Brown"}, {"brown", S("Brown")},
{"pink", "Pink"}, {"pink", S("Pink")},
{"dark_grey", "Dark Grey"}, {"dark_grey", S("Dark Grey")},
{"dark_green", "Dark Green"} {"dark_green", S("Dark Green")}
} }
-- check mod support -- check mod support
local techcnc_mod = minetest.get_modpath("technic_cnc") local techcnc_mod = minetest.get_modpath("technic_cnc")
local stairs_mod = minetest.get_modpath("stairs") local stairs_mod = minetest.get_modpath("stairs")
local stairsplus_mod = minetest.get_modpath("moreblocks") local stairsplus_mod = minetest.get_modpath("moreblocks")
@ -30,17 +34,20 @@ local stairsplus_compat = minetest.settings:get_bool("stairsplus_clay_compatibil
-- scroll through colours -- scroll through colours
for _, clay in pairs(clay) do for _, clay in pairs(clay) do
-- register node -- register node
minetest.register_node("bakedclay:" .. clay[1], { minetest.register_node("bakedclay:" .. clay[1], {
description = S(clay[2] .. " Baked Clay"), description = clay[2] .. " " .. S("Baked Clay"),
tiles = {"baked_clay_" .. clay[1] ..".png"}, tiles = {"baked_clay_" .. clay[1] ..".png"},
groups = {cracky = 3, bakedclay = 1}, groups = {cracky = 3, bakedclay = 1},
sounds = default.node_sound_stone_defaults() sounds = default.node_sound_stone_defaults()
}) })
-- register craft recipe -- register craft recipe
if clay[1] ~= "natural" then if clay[1] ~= "natural" then
minetest.register_craft({ minetest.register_craft({
@ -54,11 +61,12 @@ for _, clay in pairs(clay) do
end end
-- stairs plus -- stairs plus
if stairsplus_mod then if stairsplus_mod then
stairsplus:register_all("bakedclay", "baked_clay_" .. clay[1], stairsplus:register_all("bakedclay", "baked_clay_" .. clay[1],
"bakedclay:" .. clay[1], { "bakedclay:" .. clay[1], {
description = clay[2] .. " Baked Clay", description = clay[2] .. " " .. S("Baked Clay"),
tiles = {"baked_clay_" .. clay[1] .. ".png"}, tiles = {"baked_clay_" .. clay[1] .. ".png"},
groups = {cracky = 3}, groups = {cracky = 3},
sounds = default.node_sound_stone_defaults() sounds = default.node_sound_stone_defaults()
@ -77,29 +85,32 @@ for _, clay in pairs(clay) do
end end
-- stairs redo -- stairs redo
elseif stairs_mod and stairs.mod then elseif stairs_mod and stairs.mod then
stairs.register_all("bakedclay_" .. clay[1], "bakedclay:" .. clay[1], stairs.register_all("bakedclay_" .. clay[1], "bakedclay:" .. clay[1],
{cracky = 3}, {cracky = 3},
{"baked_clay_" .. clay[1] .. ".png"}, {"baked_clay_" .. clay[1] .. ".png"},
clay[2] .. " Baked Clay", clay[2] .. " " .. S("Baked Clay"),
default.node_sound_stone_defaults()) default.node_sound_stone_defaults())
-- default stairs -- default stairs
elseif stairs_mod then elseif stairs_mod then
stairs.register_stair_and_slab("bakedclay_".. clay[1], "bakedclay:".. clay[1], stairs.register_stair_and_slab("bakedclay_".. clay[1], "bakedclay:".. clay[1],
{cracky = 3}, {cracky = 3},
{"baked_clay_" .. clay[1] .. ".png"}, {"baked_clay_" .. clay[1] .. ".png"},
clay[2] .. " Baked Clay Stair", clay[2] .. " " .. S("Baked Clay Stair"),
clay[2] .. " Baked Clay Slab", clay[2] .. " " .. S("Baked Clay Slab"),
default.node_sound_stone_defaults()) default.node_sound_stone_defaults())
end end
-- register bakedclay for use in technic_cnc mod after all mods loaded -- register bakedclay for use in technic_cnc mod after all mods loaded
if techcnc_mod then if techcnc_mod then
core.register_on_mods_loaded(function() minetest.register_on_mods_loaded(function()
technic_cnc.register_all("bakedclay:" .. clay[1], technic_cnc.register_all("bakedclay:" .. clay[1],
{cracky = 3, not_in_creative_inventory = 1}, {cracky = 3, not_in_creative_inventory = 1},
@ -110,6 +121,7 @@ for _, clay in pairs(clay) do
end end
-- Terracotta blocks -- Terracotta blocks
for _, clay in pairs(clay) do for _, clay in pairs(clay) do
if clay[1] ~= "natural" then if clay[1] ~= "natural" then
@ -117,7 +129,7 @@ for _, clay in pairs(clay) do
local texture = "baked_clay_terracotta_" .. clay[1] ..".png" local texture = "baked_clay_terracotta_" .. clay[1] ..".png"
minetest.register_node("bakedclay:terracotta_" .. clay[1], { minetest.register_node("bakedclay:terracotta_" .. clay[1], {
description = S(clay[2] .. " Glazed Terracotta"), description = clay[2] .. " " .. S("Glazed Terracotta"),
tiles = { tiles = {
texture .. "", texture .. "",
texture .. "", texture .. "",
@ -142,7 +154,8 @@ end
minetest.register_alias("bakedclay:terracotta_light_blue", "bakedclay:terracotta_cyan") minetest.register_alias("bakedclay:terracotta_light_blue", "bakedclay:terracotta_cyan")
-- cook clay block into white baked clay -- cook clay block into natural baked clay
minetest.register_craft({ minetest.register_craft({
type = "cooking", type = "cooking",
output = "bakedclay:natural", output = "bakedclay:natural",
@ -150,6 +163,7 @@ minetest.register_craft({
}) })
-- register a few extra dye colour options -- register a few extra dye colour options
minetest.register_craft( { minetest.register_craft( {
type = "shapeless", type = "shapeless",
output = "dye:green 4", output = "dye:green 4",
@ -163,6 +177,7 @@ minetest.register_craft( {
}) })
-- only add light grey recipe if unifieddye mod isnt present (conflict) -- only add light grey recipe if unifieddye mod isnt present (conflict)
if not minetest.get_modpath("unifieddyes") then if not minetest.get_modpath("unifieddyes") then
minetest.register_craft( { minetest.register_craft( {
@ -179,6 +194,7 @@ if not minetest.get_modpath("unifieddyes") then
end end
-- 2x2 red baked clay makes 16x clay brick -- 2x2 red baked clay makes 16x clay brick
minetest.register_craft( { minetest.register_craft( {
output = "default:clay_brick 16", output = "default:clay_brick 16",
recipe = { recipe = {
@ -188,6 +204,7 @@ minetest.register_craft( {
}) })
-- colored clay compatibility -- colored clay compatibility
if minetest.settings:get_bool("colored_clay_compatibility") == true then if minetest.settings:get_bool("colored_clay_compatibility") == true then
local cc = { local cc = {
@ -224,12 +241,15 @@ if minetest.settings:get_bool("colored_clay_compatibility") == true then
end end
-- get mod path -- get mod path
local path = minetest.get_modpath("bakedclay") local path = minetest.get_modpath("bakedclay")
-- add new flowers -- add new flowers
dofile(path .. "/flowers.lua") dofile(path .. "/flowers.lua")
-- add lucky blocks if mod present -- add lucky blocks if mod present
if minetest.get_modpath("lucky_block") then if minetest.get_modpath("lucky_block") then
dofile(path .. "/lucky_block.lua") dofile(path .. "/lucky_block.lua")
end end

25
locale/template.txt Normal file

@ -0,0 +1,25 @@
# textdomain: bakedclay
Blue Delphinium=
Thistle=
Lazarus Bell=
Reed Mannagrass=
Natural=
White=
Grey=
Black=
Red=
Yellow=
Green=
Cyan=
Blue=
Magenta=
Orange=
Violet=
Brown=
Pink=
Dark Grey=
Dark Green=
Baked Clay=
Baked Clay Stair=
Baked Clay Slab=
Glazed Terracotta=