Skip to content

Translate #664

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open

Translate #664

wants to merge 22 commits into from

Conversation

VinAdmin
Copy link

The translation system has been reworked: now the mod detects the client's language and displays translations accordingly. Testing has been carried out on a multiplayer server.

Copy link
Member

@SmallJoker SmallJoker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not mergeable as of now, but it's going into a good direction. Thank you for the PR.

@@ -1,5 +1,5 @@

local S = technic.getter
local S = minetest.get_translator("technic")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you please be so nice to use core instead of minetest for newly added function calls?

Comment on lines -64 to -67
if minetest.settings:get_bool("log_mods") then
print(S("[Technic] Loaded in %f seconds"):format(os.clock() - load_start))
end

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated change. Please limit this PR to translating only.

Comment on lines -46 to -47
local clear_networks

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated change. Please do translations only.

local function register_dust(name, ingot)
local lname = string.lower(name)
lname = string.gsub(lname, ' ', '_')
minetest.register_craftitem("technic:"..lname.."_dust", {
description = S("%s Dust"):format(S(name)),
description = S(name) .. ' ' .. dust,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

S(variable) is not picked up by translation scripts, which parse files statically. S uses the translator from "technic", thus the item names are probably not translated. Did you verify this in-game?

@@ -54,7 +54,7 @@ function technic.register_base_machine(data)
"list[current_name;src;"..(4-input_size)..",1;"..input_size..",1;]"..
"list[current_name;dst;5,1;2,2;]"..
"list[current_player;main;0,5;8,4;]"..
"label[0,0;"..machine_desc:format(tier).."]"..
"label[0,0;"..machine_desc.."]"..
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other mods might still rely on the previous behaviour, thus resulting in machine names like %s Fire-o-Matic Deluxe where %s is no longer replaced by LV/MV/HV. Please add a check for %s and still format the string if necessary.

Comment on lines +249 to +256
local function replaceMk(str, mk, mode)
local t = {}
t['1'] = mk
t['2'] = mode
local str1 = str
local str2 = string.gsub(str1, "%%(%d+)", t)
return str2
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shorter, and a more intuitive function name.

Suggested change
local function replaceMk(str, mk, mode)
local t = {}
t['1'] = mk
t['2'] = mode
local str1 = str
local str2 = string.gsub(str1, "%%(%d+)", t)
return str2
end
local function get_description_string(str, mk, mode)
local t = { ["1"] = mk, ["2"] = mode }
return (string.gsub(str, "%%(%d+)", t))
end

local S = minetest.get_translator("technic_chests")

technic.chests:register(S("Copper"), "copper", {
width = 14,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functional change. Please undo.

@@ -386,11 +381,11 @@ local _TUBELIB_CALLBACKS = {
end,
}

function technic.chests:register(name, data)
function technic.chests:register(name, lname, data)
Copy link
Member

@SmallJoker SmallJoker Jul 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a breaking change. Please ensure backwards compatibility, or do the technic_chests translation in a separate PR. You could solve this trivially by passing lname in data (but handling nil values too).

for_each_registered_node(function(node_name, node_def)
if node_name ~= "default:steelblock" and
node_name:find("steelblock", 1, true) and
node_def.description:find("Steel", 1, true) then
minetest.override_item(node_name, {
description = node_def.description:gsub("Steel", S("Wrought Iron")),
description = "Steel".. tr_wrought,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SteelWrought Iron is surely not the expected outcome. I don't think this can be translated trivially.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants