engine level translation

This commit is contained in:
Vitaliy Olkhin 2025-01-01 15:30:08 +05:00 committed by Vitaliy olkhin
parent 61f3b36ed0
commit d1381f2a6f
7 changed files with 85 additions and 43 deletions

View File

@ -1,3 +1,25 @@
local S = minetest.get_translator("technic_chests")
technic.chests:register(S("Copper"), "copper", {
width = 12,
height = 5,
sort = true,
autosort = true,
infotext = false,
color = false,
locked = false,
})
technic.chests:register(S("Copper"), "copper",{
width = 12,
height = 5,
sort = true,
autosort = true,
infotext = false,
color = false,
locked = true,
})
minetest.register_craft({ minetest.register_craft({
output = 'technic:copper_chest 1', output = 'technic:copper_chest 1',
recipe = { recipe = {
@ -24,24 +46,3 @@ minetest.register_craft({
'technic:copper_chest', 'technic:copper_chest',
} }
}) })
technic.chests:register("Copper", {
width = 12,
height = 5,
sort = true,
autosort = true,
infotext = false,
color = false,
locked = false,
})
technic.chests:register("Copper", {
width = 12,
height = 5,
sort = true,
autosort = true,
infotext = false,
color = false,
locked = true,
})

View File

@ -1,3 +1,4 @@
local S = minetest.get_translator("technic_chests")
local material_list local material_list
if minetest.get_modpath("moreores") then if minetest.get_modpath("moreores") then
@ -36,7 +37,7 @@ minetest.register_craft({
} }
}) })
technic.chests:register("Gold", { technic.chests:register(S("Gold"), "gold", {
width = 15, width = 15,
height = 6, height = 6,
sort = true, sort = true,
@ -46,7 +47,7 @@ technic.chests:register("Gold", {
locked = false, locked = false,
}) })
technic.chests:register("Gold", { technic.chests:register(S("Gold"), "gold", {
width = 15, width = 15,
height = 6, height = 6,
sort = true, sort = true,

View File

@ -1,3 +1,4 @@
local S = minetest.get_translator("technic_chests")
local cast_iron_ingot local cast_iron_ingot
if minetest.get_modpath("technic_worldgen") then if minetest.get_modpath("technic_worldgen") then
cast_iron_ingot = "technic:cast_iron_ingot" cast_iron_ingot = "technic:cast_iron_ingot"
@ -32,7 +33,7 @@ minetest.register_craft({
} }
}) })
technic.chests:register("Iron", { technic.chests:register(S("Iron"), "iron", {
width = 9, width = 9,
height = 5, height = 5,
sort = true, sort = true,
@ -42,7 +43,7 @@ technic.chests:register("Iron", {
locked = false, locked = false,
}) })
technic.chests:register("Iron", { technic.chests:register(S("Iron"), "iron", {
width = 9, width = 9,
height = 5, height = 5,
sort = true, sort = true,

View File

@ -0,0 +1,39 @@
# technic_chests translation template
%s Chest =
%s Locked Chest =
%s Locked Chest (owned by %s) =
Color Filter: %s =
Edit chest description: =
# Colors
Black = Черный
Blue =
Brown =
Cyan =
Dark Green =
Dark Grey =
Green =
Grey =
Magenta =
Orange =
Pink =
Red =
Violet =
White =
Yellow =
None =
# Materials
Copper =
Gold=Золото
Iron=Железо
Mithril =
Silver =
Wooden =
# Sorting
Sort=Сортировать
Auto-sort is %s =
Off =
On =

View File

@ -1,3 +1,5 @@
local S = minetest.get_translator("technic_chests")
if minetest.get_modpath("moreores") then if minetest.get_modpath("moreores") then
minetest.register_craft({ minetest.register_craft({
output = 'technic:mithril_chest 1', output = 'technic:mithril_chest 1',
@ -27,7 +29,7 @@ minetest.register_craft({
} }
}) })
technic.chests:register("Mithril", { technic.chests:register(S("Mithril"), "mithril", {
width = 15, width = 15,
height = 6, height = 6,
sort = true, sort = true,
@ -37,7 +39,7 @@ technic.chests:register("Mithril", {
locked = false, locked = false,
}) })
technic.chests:register("Mithril", { technic.chests:register(S("Mithril"), "mithril", {
width = 15, width = 15,
height = 6, height = 6,
sort = true, sort = true,

View File

@ -1,4 +1,4 @@
local S = rawget(_G, "intllib") and intllib.Getter() or function(s) return s end local S = minetest.get_translator("technic_chests")
local pipeworks = rawget(_G, "pipeworks") local pipeworks = rawget(_G, "pipeworks")
local fs_helpers local fs_helpers
@ -207,10 +207,7 @@ local function get_receive_fields(name, data)
end end
end end
function technic.chests:definition(name, data) function technic.chests:definition(name, lname, data)
local lname = name:lower()
name = S(name)
-- Calculate formspec positions -- Calculate formspec positions
data.lowidth = 8 data.lowidth = 8
data.ovwidth = math.max(data.lowidth, data.width) data.ovwidth = math.max(data.lowidth, data.width)
@ -234,7 +231,7 @@ function technic.chests:definition(name, data)
-- Set up constant formspec fields -- Set up constant formspec fields
local fs = { local fs = {
"size["..data.ovwidth..","..data.ovheight.."]", "size["..data.ovwidth..","..data.ovheight.."]",
"label[0,0;"..S("%s Chest"):format(name).."]", "label[0,0;"..S("@1 Chest", name).."]",
"list[context;main;"..data.hileft..",1;"..data.width..","..data.height..";]", "list[context;main;"..data.hileft..",1;"..data.width..","..data.height..";]",
"list[current_player;main;"..data.loleft..","..data.lotop..";8,4;]", "list[current_player;main;"..data.loleft..","..data.lotop..";8,4;]",
"listring[]" "listring[]"
@ -260,8 +257,7 @@ function technic.chests:definition(name, data)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string("owner", placer:get_player_name() or "") meta:set_string("owner", placer:get_player_name() or "")
meta:set_string("infotext", meta:set_string("infotext",
S("%s Locked Chest (owned by %s)") S("@1 Locked Chest (owned by @2)", name, meta:get_string("owner")))
:format(name, meta:get_string("owner")))
pipeworks.after_place(pos) pipeworks.after_place(pos)
end end
table.insert(front, "technic_"..lname.."_chest_lock_overlay.png") table.insert(front, "technic_"..lname.."_chest_lock_overlay.png")
@ -271,9 +267,9 @@ function technic.chests:definition(name, data)
local desc local desc
if data.locked then if data.locked then
desc = S("%s Locked Chest"):format(name) desc = S("@1 Locked Chest", name)
else else
desc = S("%s Chest"):format(name) desc = S("@1 Chest", name)
end end
local tentry = tube_entry local tentry = tube_entry
@ -304,7 +300,7 @@ function technic.chests:definition(name, data)
on_construct = function(pos) on_construct = function(pos)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string("infotext", S("%s Chest"):format(name)) meta:set_string("infotext", S("@1 Chest", name))
set_formspec(pos, data, "main") set_formspec(pos, data, "main")
local inv = meta:get_inventory() local inv = meta:get_inventory()
inv:set_size("main", data.width * data.height) inv:set_size("main", data.width * data.height)
@ -386,11 +382,11 @@ local _TUBELIB_CALLBACKS = {
end, end,
} }
function technic.chests:register(name, data) function technic.chests:register(name, lname, data)
data = table.copy(data) -- drop reference data = table.copy(data) -- drop reference
local def = technic.chests:definition(name, data) local def = technic.chests:definition(name, lname, data)
local nn = "technic:"..name:lower()..(data.locked and "_locked" or "").."_chest" local nn = "technic:"..lname..(data.locked and "_locked" or "").."_chest"
minetest.register_node(":"..nn, def) minetest.register_node(":"..nn, def)
registered_chest_data[nn] = data registered_chest_data[nn] = data

View File

@ -1,3 +1,5 @@
local S = minetest.get_translator("technic_chests")
if minetest.get_modpath("moreores") then if minetest.get_modpath("moreores") then
minetest.register_craft({ minetest.register_craft({
output = 'technic:silver_chest', output = 'technic:silver_chest',
@ -27,7 +29,7 @@ minetest.register_craft({
} }
}) })
technic.chests:register("Silver", { technic.chests:register(S("Silver"), "silver", {
width = 12, width = 12,
height = 6, height = 6,
sort = true, sort = true,
@ -37,7 +39,7 @@ technic.chests:register("Silver", {
locked = false, locked = false,
}) })
technic.chests:register("Silver", { technic.chests:register(S("Silver"), "silver",{
width = 12, width = 12,
height = 6, height = 6,
sort = true, sort = true,