Skip to content
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

i18n #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

i18n #26

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.tr.old
55 changes: 29 additions & 26 deletions components.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
local S = minetest.get_translator("elevator")
local F = minetest.formspec_escape
local FS = function(...) return F(S(...)) end

local phash = elevator.phash
local get_node = elevator.get_node
Expand Down Expand Up @@ -86,9 +89,9 @@ if minetest.global_exists("screwdriver") then
end

minetest.register_node("elevator:shaft", {
description = "Elevator Shaft",
_doc_items_longdesc = "An elevator shaft that connects elevators to other elevators and motors.",
_doc_items_usagehelp = "Building a vertical stack of elevators and shafts with an elevator motor on top allows vertical transportation.",
description = S("Elevator Shaft"),
_doc_items_longdesc = S("An elevator shaft that connects elevators to other elevators and motors."),
_doc_items_usagehelp = S("Building a vertical stack of elevators and shafts with an elevator motor on top allows vertical transportation."),
tiles = { moditems.el_shaft_gfx },
drawtype = "nodebox",
use_texture_alpha = "clip",
Expand Down Expand Up @@ -130,9 +133,9 @@ minetest.register_node("elevator:shaft", {
})

minetest.register_node("elevator:motor", {
description = "Elevator Motor",
_doc_items_longdesc = "The engine powering an elevator shaft. Placed at the top.",
_doc_items_usagehelp = "Place the motor on the top of a stack of elevators and elevator shafts. The elevators will activate and you can then use them.",
description = S("Elevator Motor"),
_doc_items_longdesc = S("The engine powering an elevator shaft. Placed at the top."),
_doc_items_usagehelp = S("Place the motor on the top of a stack of elevators and elevator shafts. The elevators will activate and you can then use them."),
tiles = {
moditems.steel_block_image,
moditems.steel_block_image,
Expand Down Expand Up @@ -247,16 +250,16 @@ for _,mode in ipairs({"on", "off"}) do
cbox = box
end
minetest.register_node(nodename, {
description = "Elevator",
description = S("Elevator"),
drawtype = "nodebox",
sunlight_propagates = false,
paramtype = "light",
paramtype2 = "facedir",
on_rotate = moditems.on_rotate_disallow,
climbable = true,

_doc_items_longdesc = on and "An active elevator, ready for transporting." or "An inactive elevator, not connected to a motor.",
_doc_items_usagehelp = on and "Step inside this elevator and use it (right-click) to be transported to any other elevator along the shaft." or "This elevator is inactive; it is disconnected from a motor. It may be extended with shafts and other elevators in a vertical line with an elevator motor on top to power the whole shaft and enable transport.",
_doc_items_longdesc = on and S("An active elevator, ready for transporting.") or S("An inactive elevator, not connected to a motor."),
_doc_items_usagehelp = on and S("Step inside this elevator and use it (right-click) to be transported to any other elevator along the shaft.") or S("This elevator is inactive; it is disconnected from a motor. It may be extended with shafts and other elevators in a vertical line with an elevator motor on top to power the whole shaft and enable transport."),

selection_box = {
type = "fixed",
Expand Down Expand Up @@ -354,54 +357,54 @@ for _,mode in ipairs({"on", "off"}) do
for ji,jv in ipairs(motor.pnames) do
if tonumber(jv) ~= pos.y then
table.insert(tpnames, jv)
table.insert(tpnames_l, (motor.labels[ji] and motor.labels[ji] ~= "") and (jv.." - "..minetest.formspec_escape(motor.labels[ji])) or jv)
table.insert(tpnames_l, (motor.labels[ji] and motor.labels[ji] ~= "") and (jv.." - "..F(motor.labels[ji])) or jv)
end
end
elevator.formspecs[sender:get_player_name()] = {pos, tpnames}
if #tpnames > 0 then
if not minetest.is_protected(pos, sender:get_player_name()) then
formspec = "size[4,6]"
.."label[0,0;Click once to travel.]"
.."label[0,0;" .. FS("Click once to travel.") .. "]"
.."textlist[-0.1,0.5;4,4;target;"..table.concat(tpnames_l, ",").."]"
.."field[0.25,5.25;4,0;label;;"..minetest.formspec_escape(meta:get_string("label")).."]"
.."button_exit[-0.05,5.5;4,1;setlabel;Set label]"
.."field[0.25,5.25;4,0;label;;"..F(meta:get_string("label")).."]"
.."button_exit[-0.05,5.5;4,1;setlabel;" .. FS("Set label") .. "]"
else
formspec = "size[4,4.4]"
.."label[0,0;Click once to travel.]"
.."label[0,0;" .. FS("Click once to travel.") .. "]"
.."textlist[-0.1,0.5;4,4;target;"..table.concat(tpnames_l, ",").."]"
end
else
if not minetest.is_protected(pos, sender:get_player_name()) then
formspec = "size[4,2]"
.."label[0,0;No targets available.]"
.."field[0.25,1.25;4,0;label;;"..minetest.formspec_escape(meta:get_string("label")).."]"
.."button_exit[-0.05,1.5;4,1;setlabel;Set label]"
.."label[0,0;" .. FS("No targets available.") .. "]"
.."field[0.25,1.25;4,0;label;;"..F(meta:get_string("label")).."]"
.."button_exit[-0.05,1.5;4,1;setlabel;" .. FS("Set label") .. "]"
else
formspec = "size[4,0.4]"
.."label[0,0;No targets available.]"
.."label[0,0;" .. FS("No targets available.") .. "]"
end
end
minetest.show_formspec(sender:get_player_name(), "elevator:elevator", formspec)
elseif not elevator.motors[motorhash] then
if not minetest.is_protected(pos, sender:get_player_name()) then
formspec = "size[4,2]"
.."label[0,0;This elevator is inactive.]"
.."field[0.25,1.25;4,0;label;;"..minetest.formspec_escape(meta:get_string("label")).."]"
.."button_exit[-0.05,1.5;4,1;setlabel;Set label]"
.."label[0,0;" .. FS("This elevator is inactive.") .. "]"
.."field[0.25,1.25;4,0;label;;"..F(meta:get_string("label")).."]"
.."button_exit[-0.05,1.5;4,1;setlabel;" .. FS("Set label") .. "]"
else
formspec = "size[4,0.4]"
.."label[0,0;This elevator is inactive.]"
.."label[0,0;" .. FS("This elevator is inactive.") .. "]"
end
minetest.show_formspec(sender:get_player_name(), "elevator:elevator", formspec)
elseif elevator.boxes[motorhash] then
if not minetest.is_protected(pos, sender:get_player_name()) then
formspec = "size[4,2]"
.."label[0,0;This elevator is in use.]"
.."field[0.25,1.25;4,0;label;;"..minetest.formspec_escape(meta:get_string("label")).."]"
.."button_exit[-0.05,1.5;4,1;setlabel;Set label]"
.."label[0,0;" .. FS("This elevator is in use.") .. "]"
.."field[0.25,1.25;4,0;label;;"..F(meta:get_string("label")).."]"
.."button_exit[-0.05,1.5;4,1;setlabel;" .. FS("Set label") .. "]"
else
formspec = "size[4,0.4]"
.."label[0,0;This elevator is in use.]"
.."label[0,0;" .. FS("This elevator is in use.") .. "]"
end
minetest.show_formspec(sender:get_player_name(), "elevator:elevator", formspec)
end
Expand Down
15 changes: 10 additions & 5 deletions formspecs.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
local S = minetest.get_translator("elevator")
local F = minetest.formspec_escape
local FS = function(...) return F(S(...)) end

local punhash = elevator.punhash

Expand Down Expand Up @@ -30,7 +33,9 @@ minetest.register_on_player_receive_fields(function(sender, formname, fields)
-- HACK: With player information extensions enabled, we can check if closing formspecs are now allowed. This is specifically used on Survival in Ethereal.
local pi = minetest.get_player_information(sender:get_player_name())
if (not (pi.major == 0 and pi.minor == 4 and pi.patch == 15)) and (pi.protocol_version or 29) < 29 then
closeformspec = "size[4,2] label[0,0;You are now using the elevator.\nUpgrade Minetest to avoid this dialog.] button_exit[0,1;4,1;close;Close]"
closeformspec = "size[4,2]" ..
"label[0,0;" .. FS("You are now using the elevator.\nUpgrade Minetest to avoid this dialog.") .. "]" ..
"button_exit[0,1;4,1;close;" .. FS("Close") .. "]"
end
-- End hacky HACK.
minetest.after(0.2, minetest.show_formspec, sender:get_player_name(), "elevator:elevator", closeformspec)
Expand All @@ -43,12 +48,12 @@ minetest.register_on_player_receive_fields(function(sender, formname, fields)
if motor then
meta:set_string("motor", "")
elevator.build_motor(motorhash)
minetest.chat_send_player(sender:get_player_name(), "Recalibrated to a new motor, please try again.")
minetest.chat_send_player(sender:get_player_name(), S("Recalibrated to a new motor, please try again."))
return true
end
end
if not motor then
minetest.chat_send_player(sender:get_player_name(), "This elevator is not attached to a motor.")
minetest.chat_send_player(sender:get_player_name(), S("This elevator is not attached to a motor."))
return true
end
if not elevator.formspecs[sender:get_player_name()][2] or not elevator.formspecs[sender:get_player_name()][2][minetest.explode_textlist_event(fields.target).index] then
Expand All @@ -66,7 +71,7 @@ minetest.register_on_player_receive_fields(function(sender, formname, fields)
if target then
-- Final check.
if elevator.boxes[motorhash] then
minetest.chat_send_player(sender:get_player_name(), "This elevator is in use.")
minetest.chat_send_player(sender:get_player_name(), S("This elevator is in use."))
return true
end
local obj = elevator.create_box(motorhash, pos, target, sender)
Expand All @@ -81,7 +86,7 @@ minetest.register_on_player_receive_fields(function(sender, formname, fields)
end
end
else
minetest.chat_send_player(sender:get_player_name(), "This target is invalid.")
minetest.chat_send_player(sender:get_player_name(), S("This target is invalid."))
return true
end
return true
Expand Down
29 changes: 29 additions & 0 deletions locale/template.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# textdomain: elevator

##[ components.lua ]##
Elevator Shaft=
An elevator shaft that connects elevators to other elevators and motors.=
Building a vertical stack of elevators and shafts with an elevator motor on top allows vertical transportation.=
Elevator Motor=
The engine powering an elevator shaft. Placed at the top.=
Place the motor on the top of a stack of elevators and elevator shafts. The elevators will activate and you can then use them.=
Elevator=
An active elevator, ready for transporting.=
An inactive elevator, not connected to a motor.=
Step inside this elevator and use it (right-click) to be transported to any other elevator along the shaft.=
This elevator is inactive; it is disconnected from a motor. It may be extended with shafts and other elevators in a vertical line with an elevator motor on top to power the whole shaft and enable transport.=
Click once to travel.=
Set label=
No targets available.=
This elevator is inactive.=

##[ components.lua ]##
##[ formspecs.lua ]##
This elevator is in use.=

##[ formspecs.lua ]##
You are now using the elevator.@nUpgrade Minetest to avoid this dialog.=
Close=
Recalibrated to a new motor, please try again.=
This elevator is not attached to a motor.=
This target is invalid.=