Use dynamic translation for mcl_dyes and dependent mods

This commit is contained in:
Jürgen Rühle 2024-07-27 10:31:28 +02:00
parent 1d8fa06294
commit 6b1368d792
9 changed files with 39 additions and 32 deletions

View File

@ -382,7 +382,7 @@ minetest.register_node("mcl_banners:hanging_banner", {
for _, colortab in pairs(mcl_banners.colors) do
for _, pattern_name in ipairs(pattern_names) do
local itemid = colortab[1]
local desc = S("@1 Banner", mcl_dyes.colors[itemid].readable_name)
local desc = colortab[2]
local wool = colortab[3]
local colorize = colortab[4]

View File

@ -1,4 +1,5 @@
local S = minetest.get_translator(minetest.get_current_modname())
local D = mcl_util.get_dynamic_translator()
local messy_textures = { --translator table for the bed texture filenames names not adhering to the common color names of mcl_dyes
["lightblue"] = "light_blue",
@ -27,7 +28,7 @@ for color, colordef in pairs(mcl_dyes.colors) do
end
-- Register bed
mcl_beds.register_bed("mcl_beds:bed_"..color, {
description = S("@1 Bed", colordef.readable_name),
description = D(colordef.readable_name .. " Bed"),
_doc_items_entry_name = entry_name,
_doc_items_create_entry = create_entry,
inventory_image = "mcl_beds_bed_"..texcol.."_inv.png",

View File

@ -1,4 +1,5 @@
local S = minetest.get_translator(minetest.get_current_modname())
local D = mcl_util.get_dynamic_translator()
local doc_mod = minetest.get_modpath("doc")
local hc_desc = S("Terracotta is a basic building material. It comes in many different colors.")
@ -26,10 +27,10 @@ local canonical_color = "yellow"
for color,colordef in pairs(mcl_dyes.colors) do
local is_canonical = color == canonical_color
local sdesc_hc = S("@1 Terracotta", colordef.readable_name)
local sdesc_gt = S("@1 Glazed Terracotta", colordef.readable_name)
local sdesc_cp = S("@1 Concrete Powder", colordef.readable_name)
local sdesc_c = S("@1 Concrete", colordef.readable_name)
local sdesc_hc = D(colordef.readable_name .. " Terracotta")
local sdesc_gt = D(colordef.readable_name .. " Glazed Terracotta")
local sdesc_cp = D(colordef.readable_name .. " Concrete Powder")
local sdesc_c = D(colordef.readable_name .. " Concrete")
local ldesc_hc, ldesc_gt, ldesc_cp, ldesc_c
local create_entry
local ename_hc, ename_gt, ename_cp, ename_c

View File

@ -1,5 +1,6 @@
-- Glass nodes
local S = minetest.get_translator(minetest.get_current_modname())
local D = mcl_util.get_dynamic_translator()
local mod_doc = minetest.get_modpath("doc")
minetest.register_node("mcl_core:glass", {
@ -43,7 +44,7 @@ for color,colordef in pairs(mcl_dyes.colors) do
texcol = messy_textures[color]
end
minetest.register_node("mcl_core:glass_"..color, {
description = S("@1 Stained Glass", colordef.readable_name),
description = D(colordef.readable_name .. " Stained Glass"),
_doc_items_create_entry = create_entry,
_doc_items_entry_name = entry_name,
_doc_items_longdesc = longdesc,

View File

@ -5,7 +5,7 @@ This table contains all the colors indexed by cannonical color name:
```lua
{
["colorname"] = {
readable_name, --the translated "readable" name of the color to be used in descriptions
readable_name, -- the untranslated "readable" name of the color to be used in descriptions
groups, -- table of the color groups including legacy "unicolor"
rgb, -- hex RGB value of the color
unicolor, --the name of the color in the "unicolor" format

View File

@ -1,118 +1,119 @@
mcl_dyes = {}
local S = minetest.get_translator(minetest.get_current_modname())
local D = mcl_util.get_dynamic_translator()
-- Common color table to be used by other mods. The "mcl2" field if present
-- represents the name of the color in mcl2 if it is different. This is used
-- in the mcl_dye compat mod to adabt the recipes.
mcl_dyes.colors = {
["white"] = {
readable_name = S("White"),
readable_name = "White",
groups = {basecolor_white=1, excolor_white=1, unicolor_white=1},
rgb = "#d0d6d7",
unicolor = "white",
mcl2 = "white",
},
["silver"] = {
readable_name = S("Light Grey"),
readable_name = "Light Grey",
groups = {basecolor_grey=1, excolor_grey=1, unicolor_grey=1},
rgb = "#818177",
unicolor = "grey",
mcl2 = "grey",
},
["grey"] = {
readable_name = S("Grey"),
readable_name = "Grey",
groups = {basecolor_grey=1, excolor_darkgrey=1, unicolor_darkgrey=1},
rgb = "#383c40",
unicolor = "darkgrey",
mcl2 = "dark_grey",
},
["black"] = {
readable_name = S("Black"),
readable_name = "Black",
groups = {basecolor_black=1, excolor_black=1, unicolor_black=1},
rgb = "#080a10",
unicolor = "black",
mcl2 = "black",
},
["purple"] = {
readable_name = S("Purple"),
readable_name = "Purple",
groups = {basecolor_magenta=1, excolor_violet=1, unicolor_violet=1},
rgb = "#6821a0",
unicolor = "violet",
mcl2 = "violet",
},
["blue"] = {
readable_name = S("Blue"),
readable_name = "Blue",
groups = {basecolor_blue=1, excolor_blue=1, unicolor_blue=1},
rgb = "#2e3094",
unicolor = "blue",
mcl2 = "blue",
},
["light_blue"] = {
readable_name = S("Light Blue"),
readable_name = "Light Blue",
groups = {basecolor_blue=1, excolor_blue=1, unicolor_light_blue=1},
rgb = "#258ec9",
unicolor = "light_blue",
mcl2 = "lightblue",
},
["cyan"] = {
readable_name = S("Cyan"),
readable_name = "Cyan",
groups = {basecolor_cyan=1, excolor_cyan=1, unicolor_cyan=1},
rgb = "#167b8c",
unicolor = "cyan",
mcl2 = "cyan",
},
["green"] = {
readable_name = S("Green"),
readable_name = "Green",
groups = {basecolor_green=1, excolor_green=1, unicolor_dark_green=1},
rgb = "#4b5e25",
unicolor = "dark_green",
mcl2 = "dark_green",
},
["lime"] = {
readable_name = S("Lime"),
readable_name = "Lime",
groups = {basecolor_green=1, excolor_green=1, unicolor_green=1},
rgb = "#60ac19",
unicolor = "green",
mcl2 = "green",
},
["yellow"] = {
readable_name = S("Yellow"),
readable_name = "Yellow",
groups = {basecolor_yellow=1, excolor_yellow=1, unicolor_yellow=1},
rgb = "#f1b216",
unicolor = "yellow",
mcl2 = "yellow",
},
["brown"] = {
readable_name = S("Brown"),
readable_name = "Brown",
groups = {basecolor_brown=1, excolor_orange=1, unicolor_dark_orange=1},
rgb = "#633d20",
unicolor = "dark_orange",
mcl2 = "brown",
},
["orange"] = {
readable_name = S("Orange"),
readable_name = "Orange",
groups = {basecolor_orange=1, excolor_orange=1, unicolor_orange=1},
rgb = "#e26501",
unicolor = "orange",
mcl2 = "orange",
},
["red"] = {
readable_name = S("Red"),
readable_name = "Red",
groups = {basecolor_red=1, excolor_red=1, unicolor_red=1},
rgb = "#912222",
unicolor = "red",
mcl2 = "red",
},
["magenta"] = {
readable_name = S("Magenta"),
readable_name = "Magenta",
groups = {basecolor_magenta=1, excolor_red_violet=1,unicolor_red_violet=1},
rgb = "#ab31a2",
unicolor = "red_violet",
mcl2 = "magenta",
},
["pink"] = {
readable_name = S("Pink"),
readable_name = "Pink",
groups = {basecolor_red=1, excolor_red=1, unicolor_light_red=1},
rgb = "#d56791",
unicolor = "light_red",
@ -137,7 +138,7 @@ end
for k,v in pairs(mcl_dyes.colors) do
minetest.register_craftitem("mcl_dyes:" .. k, {
inventory_image = "mcl_dye_white.png^(mcl_dye_mask.png^[colorize:"..v.rgb..")",
description = S("@1 Dye", v.readable_name),
description = D(v.readable_name .. " Dye"),
_doc_items_longdesc = S("This item is a dye which is used for dyeing and crafting."),
_doc_items_usagehelp = S("Rightclick on a sheep to dye its wool. Other things are dyed by crafting."),
groups = table.update({craftitem = 1, dye = 1}, v.groups),

View File

@ -1,5 +1,6 @@
local modname = minetest.get_current_modname()
local S = minetest.get_translator(modname)
local D = mcl_util.get_dynamic_translator()
local mod_doc = minetest.get_modpath("doc")
--maps normalized base color name to non-standard texture color names
@ -249,5 +250,5 @@ pane(S("Glass Pane"), "mcl_core:glass", "_natural") -- triggers special case
-- Stained Glass Panes
for k,v in pairs(mcl_dyes.colors) do
pane(S("@1 Glass Pane", v.readable_name), "mcl_core:glass_"..k, "_"..k)
pane(D(v.readable_name .. " Stained Glass Pane"), "mcl_core:glass_"..k, "_"..k)
end

View File

@ -1,4 +1,5 @@
local S = minetest.get_translator(minetest.get_current_modname())
local D = mcl_util.get_dynamic_translator()
local mod_doc = minetest.get_modpath("doc")
-- Backwards compatibility with jordach's 16-color wool mod
@ -34,7 +35,7 @@ for color,colordef in pairs(mcl_dyes.colors) do
end
minetest.register_node("mcl_wool:"..color, {
description = S("@1 Wool", colordef.readable_name),
description = D(colordef.readable_name .. " Wool"),
_doc_items_create_entry = create_entry,
_doc_items_entry_name = name_wool,
_doc_items_longdesc = longdesc_wool,
@ -48,7 +49,7 @@ for color,colordef in pairs(mcl_dyes.colors) do
_mcl_burntime = 5
})
minetest.register_node("mcl_wool:"..color.."_carpet", {
description = S("@1 Carpet", colordef.readable_name),
description = D(colordef.readable_name .. " Carpet"),
_doc_items_create_entry = create_entry,
_doc_items_entry_name = name_carpet,
_doc_items_longdesc = longdesc_carpet,

View File

@ -1,4 +1,5 @@
local S = minetest.get_translator(minetest.get_current_modname())
local D = mcl_util.get_dynamic_translator()
local extra_nodes = minetest.settings:get_bool("mcl_extra_nodes", true)
mcl_stairs.register_stair("lapisblock", {
@ -94,16 +95,16 @@ local canonical_color = "yellow"
for name,cdef in pairs(mcl_dyes.colors) do
local is_canonical = name == canonical_color
mcl_stairs.register_stair_and_slab("concrete_"..name, {
description_stair = S("@1 Concrete Stairs", cdef.readable_name),
description_slab = S("@1 Concrete Slab", cdef.readable_name),
description_stair = D(cdef.readable_name .. " Concrete Stairs"),
description_slab = D(cdef.readable_name .. " Concrete Slab"),
groups={not_in_creative_inventory=extra_nodes and 0 or 1},
baseitem="mcl_colorblocks:concrete_"..name,
recipeitem=extra_nodes and "mcl_colorblocks:concrete_"..name or "",
})
mcl_stairs.register_stair_and_slab("hardened_clay_"..name, {
description_stair = S("@1 Terracotta Stairs", cdef.readable_name),
description_slab = S("@1 Terracotta Slab", cdef.readable_name),
description_stair = D(cdef.readable_name .. " Terracotta Stairs"),
description_slab = D(cdef.readable_name .. " Terracotta Slab"),
groups={not_in_creative_inventory=extra_nodes and 0 or 1},
baseitem="mcl_colorblocks:hardened_clay_"..name,
recipeitem=extra_nodes and "mcl_colorblocks:hardened_clay_"..name or "",