Add translation for main menu

Add engine.gettext() and remove gettext() calls in guiFormspecMenu.cpp
This commit is contained in:
sapier 2013-08-14 19:22:23 +02:00 committed by PilzAdam
parent 787b43b218
commit 09a50d0458
13 changed files with 241 additions and 224 deletions

@ -20,10 +20,10 @@ gamemgr = {}
--------------------------------------------------------------------------------
function gamemgr.dialog_new_game()
local retval =
"label[2,2;Game Name]"..
"label[2,2;" .. fgettext("Game Name") .. "]"..
"field[4.5,2.4;6,0.5;te_game_name;;]" ..
"button[5,4.2;2.6,0.5;new_game_confirm;Create]" ..
"button[7.5,4.2;2.8,0.5;new_game_cancel;Cancel]"
"button[5,4.2;2.6,0.5;new_game_confirm;" .. fgettext("Create") .. "]" ..
"button[7.5,4.2;2.8,0.5;new_game_cancel;" .. fgettext("Cancel") .. "]"
return retval
end
@ -114,8 +114,8 @@ function gamemgr.handle_edit_game_buttons(fields)
local sourcepath = mod.path
if not gamemgr.add_mod(current_game,sourcepath) then
gamedata.errormessage = "Gamemgr: Unable to copy mod: " ..
mod.name .. " to game: " .. current_game.id
gamedata.errormessage =
fgettext("Gamemgr: Unable to copy mod \"$1\" to game \"$2\"", mod.name, current_game.id)
end
end
end
@ -200,8 +200,8 @@ function gamemgr.tab()
end
local retval =
"vertlabel[0,-0.25;GAMES]" ..
"label[1,-0.25;Games:]" ..
"vertlabel[0,-0.25;" .. fgettext("GAMES") .. "]" ..
"label[1,-0.25;" .. fgettext("Games") .. ":]" ..
"textlist[1,0.25;4.5,4.4;gamelist;" ..
gamemgr.gamelist() ..
";" .. gamemgr.selected_game .. "]"
@ -217,11 +217,11 @@ function gamemgr.tab()
retval = retval ..
"field[8,-0.25;6,2;;" .. current_game.name .. ";]"..
"label[6,1.4;Mods:]" ..
"button[9.7,1.5;2,0.2;btn_game_mgr_edit_game;edit game]" ..
"label[6,1.4;" .. fgettext("Mods:") .."]" ..
"button[9.7,1.5;2,0.2;btn_game_mgr_edit_game;" .. fgettext("edit game") .. "]" ..
"textlist[6,2;5.5,3.3;game_mgr_modlist;"
.. gamemgr.get_game_mods(current_game) ..";0]" ..
"button[1,4.75;3.2,0.5;btn_game_mgr_new_game;new game]"
"button[1,4.75;3.2,0.5;btn_game_mgr_new_game;" .. fgettext("new game") .. "]"
end
return retval
end
@ -231,7 +231,7 @@ function gamemgr.dialog_edit_game()
local current_game = gamemgr.get_game(gamemgr.selected_game)
if current_game ~= nil then
local retval =
"vertlabel[0,-0.25;EDIT GAME]" ..
"vertlabel[0,-0.25;" .. fgettext("EDIT GAME") .."]" ..
"label[0,-0.25;" .. current_game.name .. "]" ..
"button[11.55,-0.2;0.75,0.5;btn_close_edit_game;x]"
@ -251,10 +251,10 @@ function gamemgr.dialog_edit_game()
.. modmgr.render_modlist() .. ";0]"
retval = retval ..
"button[0.55,4.95;4.7,0.5;btn_remove_mod_from_game;Remove selected mod]"
"button[0.55,4.95;4.7,0.5;btn_remove_mod_from_game;" .. fgettext("Remove selected mod") .."]"
retval = retval ..
"button[7.05,4.95;4.7,0.5;btn_add_mod_to_game;<<-- Add mod]"
"button[7.05,4.95;4.7,0.5;btn_add_mod_to_game;" .. fgettext("<<-- Add mod") .."]"
return retval
end

@ -24,14 +24,14 @@ local tabbuilder = {}
local worldlist = nil
--------------------------------------------------------------------------------
local function filterTP(TPlist)
TPlist2 = {"None"}
for _,i in ipairs(TPlist) do
local function filter_texture_pack_list(list)
retval = {"None"}
for _,i in ipairs(list) do
if i~="base" then
table.insert(TPlist2, i)
table.insert(retval, i)
end
end
return TPlist2
return retval
end
--------------------------------------------------------------------------------
@ -150,7 +150,7 @@ function update_menu()
"field[1,2;10,2;;ERROR: " ..
gamedata.errormessage ..
";]"..
"button[4.5,4.2;3,0.5;btn_error_confirm;Ok]"
"button[4.5,4.2;3,0.5;btn_error_confirm;" .. fgettext("Ok") .. "]"
else
formspec = formspec .. tabbuilder.gettab()
end
@ -177,12 +177,10 @@ function menu.render_world_list()
end
--------------------------------------------------------------------------------
function menu.render_TP_list(TPlist)
function menu.render_texture_pack_list(list)
local retval = ""
--local current_TP = filterlist.get_list(TPlist)
for i,v in ipairs(TPlist) do
for i,v in ipairs(list) do
if retval ~= "" then
retval = retval ..","
end
@ -292,12 +290,12 @@ function tabbuilder.dialog_create_world()
mglist = mglist:sub(1, -2)
local retval =
"label[2,0;World name]"..
"label[2,1;Mapgen]"..
"label[2,0;" .. fgettext("World name") .. "]"..
"label[2,1;" .. fgettext("Mapgen") .. "]"..
"field[4.5,0.4;6,0.5;te_world_name;;]" ..
"label[2,2;Game]"..
"button[5,4.5;2.6,0.5;world_create_confirm;Create]" ..
"button[7.5,4.5;2.8,0.5;world_create_cancel;Cancel]" ..
"label[2,2;" .. fgettext("Game") .. "]"..
"button[5,4.5;2.6,0.5;world_create_confirm;" .. fgettext("Create") .. "]" ..
"button[7.5,4.5;2.8,0.5;world_create_cancel;" .. fgettext("Cancel") .. "]" ..
"dropdown[4.2,1;6.3;dd_mapgen;" .. mglist .. ";" .. selindex .. "]" ..
"textlist[4.2,1.9;5.8,2.3;games;" ..
gamemgr.gamelist() ..
@ -308,9 +306,10 @@ end
--------------------------------------------------------------------------------
function tabbuilder.dialog_delete_world()
return "label[2,2;Delete World \"" .. filterlist.get_raw_list(worldlist)[menu.world_to_del].name .. "\"?]"..
"button[3.5,4.2;2.6,0.5;world_delete_confirm;Yes]" ..
"button[6,4.2;2.8,0.5;world_delete_cancel;No]"
return "label[2,2;" ..
fgettext("Delete World \"$1\"?", filterlist.get_raw_list(worldlist)[menu.world_to_del].name) .. "]"..
"button[3.5,4.2;2.6,0.5;world_delete_confirm;" .. fgettext("Yes").. "]" ..
"button[6,4.2;2.8,0.5;world_delete_cancel;" .. fgettext("No") .. "]"
end
--------------------------------------------------------------------------------
@ -338,7 +337,7 @@ function tabbuilder.gettab()
end
if tabbuilder.current_tab == "texture_packs" then
retval = retval .. tabbuilder.tab_TP()
retval = retval .. tabbuilder.tab_texture_packs()
end
if tabbuilder.current_tab == "credits" then
@ -378,7 +377,7 @@ function tabbuilder.handle_create_world_buttons(fields)
engine.setting_set("mg_name",fields["dd_mapgen"])
message = engine.create_world(worldname,gameindex)
else
message = "A world named \"" .. worldname .. "\" already exists"
message = fgettext("A world named \"$1\" already exists", worldname)
end
if message ~= nil then
@ -392,7 +391,8 @@ function tabbuilder.handle_create_world_buttons(fields)
filterlist.raw_index_by_uid(worldlist,worldname))
end
else
gamedata.errormessage = "No worldname given or no game selected"
gamedata.errormessage =
fgettext("No worldname given or no game selected")
end
end
@ -766,18 +766,21 @@ function tabbuilder.handle_singleplayer_buttons(fields)
end
--------------------------------------------------------------------------------
function tabbuilder.handle_TP_buttons(fields)
function tabbuilder.handle_texture_pack_buttons(fields)
if fields["TPs"] ~= nil then
local event = explode_textlist_event(fields["TPs"])
if event.typ == "CHG" or event.typ=="DCL" then
local index = engine.get_textlist_index("TPs")
engine.setting_set("mainmenu_last_selected_TP",
index)
local TPlist = filterTP(engine.get_dirlist(engine.get_texturepath(), true))
local TPname = TPlist[engine.get_textlist_index("TPs")]
local TPpath = engine.get_texturepath()..DIR_DELIM..TPname
if TPname == "None" then TPpath = "" end
engine.setting_set("texture_path", TPpath)
local list = filter_texture_pack_list(engine.get_dirlist(engine.get_texturepath(), true))
local current_index = engine.get_textlist_index("TPs")
if #list >= current_index then
local new_path = engine.get_texturepath()..DIR_DELIM..list[current_index]
if list[current_index] == "None" then new_path = "" end
engine.setting_set("texture_path", new_path)
end
end
end
end
@ -842,20 +845,20 @@ function tabbuilder.init()
tabbuilder.show_buttons = true
tabbuilder.current_buttons = {}
table.insert(tabbuilder.current_buttons,{name="singleplayer", caption="Singleplayer"})
table.insert(tabbuilder.current_buttons,{name="multiplayer", caption="Client"})
table.insert(tabbuilder.current_buttons,{name="server", caption="Server"})
table.insert(tabbuilder.current_buttons,{name="settings", caption="Settings"})
table.insert(tabbuilder.current_buttons,{name="texture_packs", caption="Texture Packs"})
table.insert(tabbuilder.current_buttons,{name="singleplayer", caption=fgettext("Singleplayer")})
table.insert(tabbuilder.current_buttons,{name="multiplayer", caption=fgettext("Client")})
table.insert(tabbuilder.current_buttons,{name="server", caption=fgettext("Server")})
table.insert(tabbuilder.current_buttons,{name="settings", caption=fgettext("Settings")})
table.insert(tabbuilder.current_buttons,{name="texture_packs", caption=fgettext("Texture Packs")})
if engine.setting_getbool("main_menu_game_mgr") then
table.insert(tabbuilder.current_buttons,{name="game_mgr", caption="Games"})
table.insert(tabbuilder.current_buttons,{name="game_mgr", caption=fgettext("Games")})
end
if engine.setting_getbool("main_menu_mod_mgr") then
table.insert(tabbuilder.current_buttons,{name="mod_mgr", caption="Mods"})
table.insert(tabbuilder.current_buttons,{name="mod_mgr", caption=fgettext("Mods")})
end
table.insert(tabbuilder.current_buttons,{name="credits", caption="Credits"})
table.insert(tabbuilder.current_buttons,{name="credits", caption=fgettext("Credits")})
for i=1,#tabbuilder.current_buttons,1 do
@ -875,22 +878,22 @@ end
function tabbuilder.tab_multiplayer()
local retval =
"vertlabel[0,-0.25;CLIENT]" ..
"label[1,-0.25;Favorites:]"..
"label[1,4.25;Address/Port]"..
"label[9,2.75;Name/Password]" ..
"vertlabel[0,-0.25;".. fgettext("CLIENT") .. "]" ..
"label[1,-0.25;".. fgettext("Favorites:") .. "]"..
"label[1,4.25;".. fgettext("Address/Port") .. "]"..
"label[9,2.75;".. fgettext("Name/Password") .. "]" ..
"field[1.25,5.25;5.5,0.5;te_address;;" ..engine.setting_get("address") .."]" ..
"field[6.75,5.25;2.25,0.5;te_port;;" ..engine.setting_get("port") .."]" ..
"checkbox[1,3.6;cb_public_serverlist;Public Serverlist;" ..
"checkbox[1,3.6;cb_public_serverlist;".. fgettext("Public Serverlist") .. ";" ..
dump(engine.setting_getbool("public_serverlist")) .. "]"
if not engine.setting_getbool("public_serverlist") then
retval = retval ..
"button[6.45,3.95;2.25,0.5;btn_delete_favorite;Delete]"
"button[6.45,3.95;2.25,0.5;btn_delete_favorite;".. fgettext("Delete") .. "]"
end
retval = retval ..
"button[9,4.95;2.5,0.5;btn_mp_connect;Connect]" ..
"button[9,4.95;2.5,0.5;btn_mp_connect;".. fgettext("Connect") .. "]" ..
"field[9.3,3.75;2.5,0.5;te_name;;" ..engine.setting_get("name") .."]" ..
"pwdfield[9.3,4.5;2.5,0.5;te_pwd;]" ..
"textarea[9.3,0.25;2.5,2.75;;"
@ -931,22 +934,22 @@ function tabbuilder.tab_server()
)
local retval =
"button[4,4.15;2.6,0.5;world_delete;Delete]" ..
"button[6.5,4.15;2.8,0.5;world_create;New]" ..
"button[9.2,4.15;2.55,0.5;world_configure;Configure]" ..
"button[8.5,4.9;3.25,0.5;start_server;Start Game]" ..
"label[4,-0.25;Select World:]"..
"vertlabel[0,-0.25;START SERVER]" ..
"checkbox[0.5,0.25;cb_creative_mode;Creative Mode;" ..
"button[4,4.15;2.6,0.5;world_delete;".. fgettext("Delete") .. "]" ..
"button[6.5,4.15;2.8,0.5;world_create;".. fgettext("New") .. "]" ..
"button[9.2,4.15;2.55,0.5;world_configure;".. fgettext("Configure") .. "]" ..
"button[8.5,4.9;3.25,0.5;start_server;".. fgettext("Start Game") .. "]" ..
"label[4,-0.25;".. fgettext("Select World:") .. "]"..
"vertlabel[0,-0.25;".. fgettext("START SERVER") .. "]" ..
"checkbox[0.5,0.25;cb_creative_mode;".. fgettext("Creative Mode") .. ";" ..
dump(engine.setting_getbool("creative_mode")) .. "]"..
"checkbox[0.5,0.7;cb_enable_damage;Enable Damage;" ..
"checkbox[0.5,0.7;cb_enable_damage;".. fgettext("Enable Damage") .. ";" ..
dump(engine.setting_getbool("enable_damage")) .. "]"..
"checkbox[0.5,1.15;cb_server_announce;Public;" ..
"checkbox[0.5,1.15;cb_server_announce;".. fgettext("Public") .. ";" ..
dump(engine.setting_getbool("server_announce")) .. "]"..
"field[0.8,3.2;3,0.5;te_playername;Name;" ..
"field[0.8,3.2;3,0.5;te_playername;".. fgettext("Name") .. ";" ..
engine.setting_get("name") .. "]" ..
"pwdfield[0.8,4.2;3,0.5;te_passwd;Password]" ..
"field[0.8,5.2;3,0.5;te_serverport;Server Port;30000]" ..
"pwdfield[0.8,4.2;3,0.5;te_passwd;".. fgettext("Password") .. "]" ..
"field[0.8,5.2;3,0.5;te_serverport;".. fgettext("Server Port") .. ";30000]" ..
"textlist[4,0.25;7.5,3.7;srv_worlds;" ..
menu.render_world_list() ..
";" .. index .. "]"
@ -956,23 +959,35 @@ end
--------------------------------------------------------------------------------
function tabbuilder.tab_settings()
return "vertlabel[0,0;SETTINGS]" ..
"checkbox[1,0.75;cb_fancy_trees;Fancy trees;" .. dump(engine.setting_getbool("new_style_leaves")) .. "]"..
"checkbox[1,1.25;cb_smooth_lighting;Smooth Lighting;".. dump(engine.setting_getbool("smooth_lighting")) .. "]"..
"checkbox[1,1.75;cb_3d_clouds;3D Clouds;" .. dump(engine.setting_getbool("enable_3d_clouds")) .. "]"..
"checkbox[1,2.25;cb_opaque_water;Opaque Water;" .. dump(engine.setting_getbool("opaque_water")) .. "]"..
return "vertlabel[0,0;" .. fgettext("SETTINGS") .. "]" ..
"checkbox[1,0.75;cb_fancy_trees;".. fgettext("Fancy trees") .. ";"
.. dump(engine.setting_getbool("new_style_leaves")) .. "]"..
"checkbox[1,1.25;cb_smooth_lighting;".. fgettext("Smooth Lighting")
.. ";".. dump(engine.setting_getbool("smooth_lighting")) .. "]"..
"checkbox[1,1.75;cb_3d_clouds;".. fgettext("3D Clouds") .. ";"
.. dump(engine.setting_getbool("enable_3d_clouds")) .. "]"..
"checkbox[1,2.25;cb_opaque_water;".. fgettext("Opaque Water") .. ";"
.. dump(engine.setting_getbool("opaque_water")) .. "]"..
"checkbox[4,0.75;cb_mipmapping;Mip-Mapping;" .. dump(engine.setting_getbool("mip_map")) .. "]"..
"checkbox[4,1.25;cb_anisotrophic;Anisotropic Filtering;".. dump(engine.setting_getbool("anisotropic_filter")) .. "]"..
"checkbox[4,1.75;cb_bilinear;Bi-Linear Filtering;" .. dump(engine.setting_getbool("bilinear_filter")) .. "]"..
"checkbox[4,2.25;cb_trilinear;Tri-Linear Filtering;" .. dump(engine.setting_getbool("trilinear_filter")) .. "]"..
"checkbox[4,0.75;cb_mipmapping;".. fgettext("Mip-Mapping") .. ";"
.. dump(engine.setting_getbool("mip_map")) .. "]"..
"checkbox[4,1.25;cb_anisotrophic;".. fgettext("Anisotropic Filtering") .. ";"
.. dump(engine.setting_getbool("anisotropic_filter")) .. "]"..
"checkbox[4,1.75;cb_bilinear;".. fgettext("Bi-Linear Filtering") .. ";"
.. dump(engine.setting_getbool("bilinear_filter")) .. "]"..
"checkbox[4,2.25;cb_trilinear;".. fgettext("Tri-Linear Filtering") .. ";"
.. dump(engine.setting_getbool("trilinear_filter")) .. "]"..
"checkbox[7.5,0.75;cb_shaders;Shaders;" .. dump(engine.setting_getbool("enable_shaders")) .. "]"..
"checkbox[7.5,1.25;cb_pre_ivis;Preload item visuals;".. dump(engine.setting_getbool("preload_item_visuals")) .. "]"..
"checkbox[7.5,1.75;cb_particles;Enable Particles;" .. dump(engine.setting_getbool("enable_particles")) .. "]"..
"checkbox[7.5,2.25;cb_finite_liquid;Finite Liquid;" .. dump(engine.setting_getbool("liquid_finite")) .. "]"..
"checkbox[7.5,0.75;cb_shaders;".. fgettext("Shaders") .. ";"
.. dump(engine.setting_getbool("enable_shaders")) .. "]"..
"checkbox[7.5,1.25;cb_pre_ivis;".. fgettext("Preload item visuals") .. ";"
.. dump(engine.setting_getbool("preload_item_visuals")) .. "]"..
"checkbox[7.5,1.75;cb_particles;".. fgettext("Enable Particles") .. ";"
.. dump(engine.setting_getbool("enable_particles")) .. "]"..
"checkbox[7.5,2.25;cb_finite_liquid;".. fgettext("Finite Liquid") .. ";"
.. dump(engine.setting_getbool("liquid_finite")) .. "]"..
"button[1,4.25;2.25,0.5;btn_change_keys;Change keys]"
"button[1,4.25;2.25,0.5;btn_change_keys;".. fgettext("Change keys") .. "]"
end
--------------------------------------------------------------------------------
@ -982,15 +997,15 @@ function tabbuilder.tab_singleplayer()
tonumber(engine.setting_get("mainmenu_last_selected_world"))
)
return "button[4,4.15;2.6,0.5;world_delete;Delete]" ..
"button[6.5,4.15;2.8,0.5;world_create;New]" ..
"button[9.2,4.15;2.55,0.5;world_configure;Configure]" ..
"button[8.5,4.95;3.25,0.5;play;Play]" ..
"label[4,-0.25;Select World:]"..
"vertlabel[0,-0.25;SINGLE PLAYER]" ..
"checkbox[0.5,0.25;cb_creative_mode;Creative Mode;" ..
return "button[4,4.15;2.6,0.5;world_delete;".. fgettext("Delete") .. "]" ..
"button[6.5,4.15;2.8,0.5;world_create;".. fgettext("New") .. "]" ..
"button[9.2,4.15;2.55,0.5;world_configure;".. fgettext("Configure") .. "]" ..
"button[8.5,4.95;3.25,0.5;play;".. fgettext("Play") .. "]" ..
"label[4,-0.25;".. fgettext("Select World:") .. "]"..
"vertlabel[0,-0.25;".. fgettext("SINGLE PLAYER") .. "]" ..
"checkbox[0.5,0.25;cb_creative_mode;".. fgettext("Creative Mode") .. ";" ..
dump(engine.setting_getbool("creative_mode")) .. "]"..
"checkbox[0.5,0.7;cb_enable_damage;Enable Damage;" ..
"checkbox[0.5,0.7;cb_enable_damage;".. fgettext("Enable Damage") .. ";" ..
dump(engine.setting_getbool("enable_damage")) .. "]"..
"textlist[4,0.25;7.5,3.7;sp_worlds;" ..
menu.render_world_list() ..
@ -999,44 +1014,47 @@ function tabbuilder.tab_singleplayer()
end
--------------------------------------------------------------------------------
function tabbuilder.tab_TP()
local TPpath = engine.setting_get("texture_path")
local TPlist = filterTP(engine.get_dirlist(engine.get_texturepath(), true))
function tabbuilder.tab_texture_packs()
local retval = "label[4,-0.25;".. fgettext("Select texture pack:") .. "]"..
"vertlabel[0,-0.25;".. fgettext("TEXTURE PACKS") .. "]" ..
"textlist[4,0.25;7.5,5.0;TPs;"
local current_texture_path = engine.setting_get("texture_path")
local list = filter_texture_pack_list(engine.get_dirlist(engine.get_texturepath(), true))
local index = tonumber(engine.setting_get("mainmenu_last_selected_TP"))
if index == nil then index = 1 end
if TPpath == "" then
return "label[4,-0.25;Select texture pack:]"..
"vertlabel[0,-0.25;TEXTURE PACKS]" ..
"textlist[4,0.25;7.5,5.0;TPs;" ..
menu.render_TP_list(TPlist) ..
if current_texture_path == "" then
retval = retval ..
menu.render_texture_pack_list(list) ..
";" .. index .. "]"
return retval
end
local TPinfofile = TPpath..DIR_DELIM.."info.txt"
local f = io.open(TPinfofile, "r")
local infofile = current_texture_path ..DIR_DELIM.."info.txt"
local infotext = ""
local f = io.open(infofile, "r")
if f==nil then
menu.TPinfo = "No information available"
infotext = fgettext("No information available")
else
menu.TPinfo = f:read("*all")
f:close()
end
local TPscreenfile = TPpath..DIR_DELIM.."screenshot.png"
local f = io.open(TPscreenfile, "r")
if f==nil then
menu.TPscreen = nil
else
menu.TPscreen = TPscreenfile
infotext = f:read("*all")
f:close()
end
local no_screenshot = engine.get_texturepath()..DIR_DELIM.."base"..DIR_DELIM.."pack"..DIR_DELIM.."no_screenshot.png"
local screenfile = current_texture_path..DIR_DELIM.."screenshot.png"
local no_screenshot = nil
if not file_exists(screenfile) then
screenfile = nil
no_screenshot = engine.get_texturepath()..DIR_DELIM..
"base"..DIR_DELIM.."pack"..DIR_DELIM.."no_screenshot.png"
end
return "label[4,-0.25;Select texture pack:]"..
"vertlabel[0,-0.25;TEXTURE PACKS]" ..
"textlist[4,0.25;7.5,5.0;TPs;" ..
menu.render_TP_list(TPlist) ..
return retval ..
menu.render_texture_pack_list(list) ..
";" .. index .. "]" ..
"image[0.65,0.25;4.0,3.7;"..(menu.TPscreen or no_screenshot).."]"..
"textarea[1.0,3.25;3.7,1.5;;"..engine.formspec_escape(menu.TPinfo or "")..";]"
"image[0.65,0.25;4.0,3.7;"..(screenfile or no_screenshot).."]"..
"textarea[1.0,3.25;3.7,1.5;;"..engine.formspec_escape(infotext or "")..";]"
end
--------------------------------------------------------------------------------
@ -1046,7 +1064,7 @@ function tabbuilder.tab_credits()
"label[0.5,3.3;http://minetest.net]" ..
"image[0.5,1;" .. menu.defaulttexturedir .. "logo.png]" ..
"textlist[3.5,-0.25;8.5,5.8;list_credits;" ..
"#FFFF00Core Developers," ..
"#FFFF00" .. fgettext("Core Developers") .."," ..
"Perttu Ahola (celeron55) <celeron55@gmail.com>,"..
"Ryan Kwolek (kwolekr) <kwolekr@minetest.net>,"..
"PilzAdam <pilzadam@minetest.net>," ..
@ -1057,7 +1075,7 @@ function tabbuilder.tab_credits()
"sfan5 <sfan5@live.de>,"..
"kahrl <kahrl@gmx.net>,"..
","..
"#FFFF00Active Contributors," ..
"#FFFF00" .. fgettext("Active Contributors") .. "," ..
"sapier,"..
"Vanessa Ezekowitz (VanessaE) <vanessaezekowitz@gmail.com>,"..
"Jurgen Doser (doserj) <jurgen.doser@gmail.com>,"..
@ -1067,7 +1085,7 @@ function tabbuilder.tab_credits()
"dannydark <the_skeleton_of_a_child@yahoo.co.uk>,"..
"0gb.us <0gb.us@0gb.us>,"..
"," ..
"#FFFF00Previous Contributors," ..
"#FFFF00" .. fgettext("Previous Contributors") .. "," ..
"Guiseppe Bilotta (Oblomov) <guiseppe.bilotta@gmail.com>,"..
"Jonathan Neuschafer <j.neuschaefer@gmx.net>,"..
"Nils Dagsson Moskopp (erlehmann) <nils@dieweltistgarnichtso.net>,"..
@ -1133,7 +1151,7 @@ engine.button_handler = function(fields)
end
if tabbuilder.current_tab == "texture_packs" then
tabbuilder.handle_TP_buttons(fields)
tabbuilder.handle_texture_pack_buttons(fields)
end
if tabbuilder.current_tab == "multiplayer" then

@ -85,6 +85,17 @@ function string:split(sep)
return fields
end
--------------------------------------------------------------------------------
function file_exists(filename)
local f = io.open(filename, "r")
if f==nil then
return false
else
f:close()
return true
end
end
--------------------------------------------------------------------------------
function string:trim()
return (self:gsub("^%s*(.-)%s*$", "%1"))
@ -92,8 +103,6 @@ end
assert(string.trim("\n \t\tfoo bar\t ") == "foo bar")
--------------------------------------------------------------------------------
function math.hypot(x, y)
local t
@ -209,6 +218,29 @@ if engine ~= nil then
return nil
end
function fgettext(text, ...)
text = engine.gettext(text)
local arg = {n=select('#', ...), ...}
if arg.n >= 1 then
-- Insert positional parameters ($1, $2, ...)
result = ''
pos = 1
while pos <= text:len() do
newpos = text:find('[$]', pos)
if newpos == nil then
result = result .. text:sub(pos)
pos = text:len() + 1
else
paramindex = tonumber(text:sub(newpos+1, newpos+1))
result = result .. text:sub(pos, newpos-1) .. tostring(arg[paramindex])
pos = newpos + 2
end
end
text = result
end
return engine.formspec_escape(text)
end
end
--------------------------------------------------------------------------------
-- core only fct

@ -233,15 +233,15 @@ function modmgr.tab()
end
local retval =
"vertlabel[0,-0.25;MODS]" ..
"label[0.8,-0.25;Installed Mods:]" ..
"vertlabel[0,-0.25;".. fgettext("MODS") .. "]" ..
"label[0.8,-0.25;".. fgettext("Installed Mods:") .. "]" ..
"textlist[0.75,0.25;4.5,4.3;modlist;" ..
modmgr.render_modlist(modmgr.global_mods) ..
";" .. modmgr.selected_mod .. "]"
retval = retval ..
"button[1,4.85;2,0.5;btn_mod_mgr_install_local;Install]" ..
"button[3,4.85;2,0.5;btn_mod_mgr_download;Download]"
"button[1,4.85;2,0.5;btn_mod_mgr_install_local;".. fgettext("Install") .. "]" ..
"button[3,4.85;2,0.5;btn_mod_mgr_download;".. fgettext("Download") .. "]"
local selected_mod = nil
@ -251,11 +251,13 @@ function modmgr.tab()
if selected_mod ~= nil then
if selected_mod.is_modpack then
retval = retval .. "button[10,4.85;2,0.5;btn_mod_mgr_rename_modpack;Rename]"
retval = retval
.. "button[10,4.85;2,0.5;btn_mod_mgr_rename_modpack;" ..
fgettext("Rename") .. "]"
else
--show dependencies
retval = retval ..
"label[6,1.9;Depends:]" ..
"label[6,1.9;".. fgettext("Depends:") .. "]" ..
"textlist[6,2.4;5.7,2;deplist;"
toadd = modmgr.get_dependencies(selected_mod.path)
@ -265,7 +267,8 @@ function modmgr.tab()
--TODO read modinfo
end
--show delete button
retval = retval .. "button[8,4.85;2,0.5;btn_mod_mgr_delete_mod;Delete]"
retval = retval .. "button[8,4.85;2,0.5;btn_mod_mgr_delete_mod;"
.. fgettext("Delete") .. "]"
end
return retval
end
@ -276,12 +279,14 @@ function modmgr.dialog_rename_modpack()
local mod = filterlist.get_list(modmgr.modlist)[modmgr.selected_mod]
local retval =
"label[1.75,1;Rename Modpack:]"..
"label[1.75,1;".. fgettext("Rename Modpack:") .. "]"..
"field[4.5,1.4;6,0.5;te_modpack_name;;" ..
mod.name ..
"]" ..
"button[5,4.2;2.6,0.5;dlg_rename_modpack_confirm;Accept]" ..
"button[7.5,4.2;2.8,0.5;dlg_rename_modpack_cancel;Cancel]"
"button[5,4.2;2.6,0.5;dlg_rename_modpack_confirm;"..
fgettext("Accept") .. "]" ..
"button[7.5,4.2;2.8,0.5;dlg_rename_modpack_cancel;"..
fgettext("Cancel") .. "]"
return retval
end
@ -369,31 +374,32 @@ function modmgr.dialog_configure_world()
local retval =
"size[11,6.5]" ..
"label[1.5,-0.25;World: " .. worldspec.name .. "]"
"label[0.5,-0.25;" .. fgettext("World:") .. "]" ..
"label[1.75,-0.25;" .. worldspec.name .. "]"
if modmgr.hide_gamemods then
retval = retval .. "checkbox[0,5.75;cb_hide_gamemods;Hide Game;true]"
retval = retval .. "checkbox[0,5.75;cb_hide_gamemods;" .. fgettext("Hide Game") .. ";true]"
else
retval = retval .. "checkbox[0,5.75;cb_hide_gamemods;Hide Game;false]"
retval = retval .. "checkbox[0,5.75;cb_hide_gamemods;" .. fgettext("Hide Game") .. ";false]"
end
if modmgr.hide_modpackcontents then
retval = retval .. "checkbox[2,5.75;cb_hide_mpcontent;Hide mp content;true]"
retval = retval .. "checkbox[2,5.75;cb_hide_mpcontent;" .. fgettext("Hide mp content") .. ";true]"
else
retval = retval .. "checkbox[2,5.75;cb_hide_mpcontent;Hide mp content;false]"
retval = retval .. "checkbox[2,5.75;cb_hide_mpcontent;" .. fgettext("Hide mp content") .. ";false]"
end
if mod == nil then
mod = {name=""}
end
retval = retval ..
"label[0,0.45;Mod:]" ..
"label[0,0.45;" .. fgettext("Mod:") .. "]" ..
"label[0.75,0.45;" .. mod.name .. "]" ..
"label[0,1;Depends:]" ..
"label[0,1;" .. fgettext("Depends:") .. "]" ..
"textlist[0,1.5;5,4.25;world_config_depends;" ..
modmgr.get_dependencies(mod.path) .. ";0]" ..
"button[9.25,6.35;2,0.5;btn_config_world_save;Save]" ..
"button[7.4,6.35;2,0.5;btn_config_world_cancel;Cancel]"
"button[9.25,6.35;2,0.5;btn_config_world_save;" .. fgettext("Save") .. "]" ..
"button[7.4,6.35;2,0.5;btn_config_world_cancel;" .. fgettext("Cancel") .. "]"
if mod ~= nil and mod.name ~= "" then
if mod.is_modpack then
@ -409,22 +415,21 @@ function modmgr.dialog_configure_world()
end
if all_enabled == false then
retval = retval .. "button[5.5,-0.125;2,0.5;btn_mp_enable;Enable MP]"
retval = retval .. "button[5.5,-0.125;2,0.5;btn_mp_enable;" .. fgettext("Enable MP") .. "]"
else
retval = retval .. "button[5.5,-0.125;2,0.5;btn_mp_disable;Disable MP]"
retval = retval .. "button[5.5,-0.125;2,0.5;btn_mp_disable;" .. fgettext("Disable MP") .. "]"
end
else
if mod.enabled then
retval = retval .. "checkbox[5.5,-0.375;cb_mod_enable;enabled;true]"
retval = retval .. "checkbox[5.5,-0.375;cb_mod_enable;" .. fgettext("enabled") .. ";true]"
else
retval = retval .. "checkbox[5.5,-0.375;cb_mod_enable;enabled;false]"
retval = retval .. "checkbox[5.5,-0.375;cb_mod_enable;" .. fgettext("enabled") .. ";false]"
end
end
end
retval = retval ..
"button[8.5,-0.125;2.5,0.5;btn_all_mods;Enable all]" ..
"button[8.5,-0.125;2.5,0.5;btn_all_mods;" .. fgettext("Enable all") .. "]" ..
"textlist[5.5,0.5;5.5,5.75;world_config_modlist;"
retval = retval .. modmgr.render_modlist(modmgr.modlist)
@ -540,7 +545,7 @@ function modmgr.handle_modmgr_buttons(fields)
end
if fields["btn_mod_mgr_install_local"] ~= nil then
engine.show_file_open_dialog("mod_mgt_open_dlg","Select Mod File:")
engine.show_file_open_dialog("mod_mgt_open_dlg",fgettext("Select Mod File:"))
end
if fields["btn_mod_mgr_download"] ~= nil then
@ -579,8 +584,8 @@ function modmgr.installmod(modfilename,basename)
local modpath = modmgr.extract(modfile)
if modpath == nil then
gamedata.errormessage = "Install Mod: file: " .. modfile.name ..
"\nInstall Mod: unsupported filetype \"" .. modfile.type .. "\""
gamedata.errormessage = fgettext("Install Mod: file: \"$1\"", modfile.name) ..
fgettext("\nInstall Mod: unsupported filetype \"$1\"", modfile.type)
return
end
@ -601,11 +606,10 @@ function modmgr.installmod(modfilename,basename)
if clean_path ~= nil then
local targetpath = engine.get_modpath() .. DIR_DELIM .. clean_path
if not engine.copy_dir(basefolder.path,targetpath) then
gamedata.errormessage = "Failed to install " .. basename .. " to " .. targetpath
gamedata.errormessage = fgettext("Failed to install $1 to $2", basename, targetpath)
end
else
gamedata.errormessage = "Install Mod: unable to find suitable foldername for modpack "
.. modfilename
gamedata.errormessage = fgettext("Install Mod: unable to find suitable foldername for modpack $1", modfilename)
end
end
@ -625,8 +629,7 @@ function modmgr.installmod(modfilename,basename)
local targetpath = engine.get_modpath() .. DIR_DELIM .. targetfolder
engine.copy_dir(basefolder.path,targetpath)
else
gamedata.errormessage = "Install Mod: unable to find real modname for: "
.. modfilename
gamedata.errormessage = fgettext("Install Mod: unable to find real modname for: $1", modfilename)
end
end
@ -824,11 +827,11 @@ function modmgr.handle_delete_mod_buttons(fields)
mod.path ~= "" and
mod.path ~= engine.get_modpath() then
if not engine.delete_dir(mod.path) then
gamedata.errormessage ="Modmgr: failed to delete >" .. mod.path .. "<"
gamedata.errormessage = fgettext("Modmgr: failed to delete \"$1\"", mod.path)
end
modmgr.refresh_globals()
else
gamedata.errormessage ="Modmgr: invalid modpath >" .. mod.path .. "<"
gamedata.errormessage = fgettext("Modmgr: invalid modpath \"$1\"", mod.path)
end
end
@ -845,9 +848,9 @@ function modmgr.dialog_delete_mod()
local mod = filterlist.get_list(modmgr.global_mods)[modmgr.selected_mod]
local retval =
"field[1.75,1;10,3;;Are you sure you want to delete ".. mod.name .. "?;]"..
"button[4,4.2;1,0.5;dlg_delete_mod_confirm;Yes]" ..
"button[6.5,4.2;3,0.5;dlg_delete_mod_cancel;No of course not!]"
"field[1.75,1;10,3;;" .. fgettext("Are you sure you want to delete \"$1\"?", mod.name) .. ";]"..
"button[4,4.2;1,0.5;dlg_delete_mod_confirm;" .. fgettext("Yes") .. "]" ..
"button[6.5,4.2;3,0.5;dlg_delete_mod_cancel;" .. fgettext("No of course not!") .. "]"
return retval
end

@ -180,8 +180,7 @@ end
--------------------------------------------------------------------------------
function modstore.getmodlist(list)
local retval = ""
retval = retval .. "label[10,-0.4;Page " .. (list.page +1) ..
" of " .. list.pagecount .. "]"
retval = retval .. "label[10,-0.4;" .. fgettext("Page $1 of $2", list.page+1, list.pagecount) .. "]"
retval = retval .. "button[11.6,-0.1;0.5,0.5;btn_modstore_page_up;^]"
retval = retval .. "box[11.6,0.35;0.28,8.6;000000]"
@ -240,7 +239,8 @@ function modstore.getmodlist(list)
engine.formspec_escape(details.description) .. ";]"
--rating
local ratingy = screenshot_ypos + 0.6
retval = retval .."label[10.1," .. ratingy .. ";Rating: " .. details.rating .."]"
retval = retval .."label[10.1," .. ratingy .. ";" ..
fgettext("Rating") .. ": " .. details.rating .."]"
--install button
local buttony = screenshot_ypos + 1.2
@ -248,9 +248,9 @@ function modstore.getmodlist(list)
retval = retval .."button[9.6," .. buttony .. ";2,0.5;btn_install_mod_" .. buttonnumber .. ";"
if modmgr.mod_exists(details.basename) then
retval = retval .. "re-Install]"
retval = retval .. fgettext("re-Install") .."]"
else
retval = retval .. "Install]"
retval = retval .. fgettext("Install") .."]"
end
end
end

@ -1068,8 +1068,7 @@ minetest.pos_to_string({x=X,y=Y,z=Z}) -> "(X,Y,Z)"
^ Convert position to a printable string
minetest.string_to_pos(string) -> position
^ Same but in reverse
minetest.formspec_escape(string) -> string
^ escapes characters like [, ], and \ that can not be used in formspecs
^ escapes characters [ ] \ , ; that can not be used in formspecs
minetest namespace reference
-----------------------------

@ -167,6 +167,13 @@ engine.file_open_dialog(formname,caption)
^ returns nil or selected file/folder
Helpers:
engine.formspec_escape(string) -> string
^ escapes characters [ ] \ , ; that can not be used in formspecs
engine.gettext(string) -> string
^ look up the translation of a string in the gettext message catalog
fgettext(string, ...) -> string
^ call engine.gettext(string), replace "$1"..."$9" with the given
^ extra arguments, call engine.formspec_escape and return the result
dump(obj, dumped={})
^ Return object serialized as a string
string:split(separator)

@ -136,7 +136,6 @@ GUIEngine::GUIEngine( irr::IrrlichtDevice* dev,
m_menu->lockSize(true,v2u32(800,600));
m_menu->setFormSource(m_formspecgui);
m_menu->setTextDest(m_buttonhandler);
m_menu->useGettext(true);
// Initialize scripting

@ -44,10 +44,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "util/numeric.h"
#include "filesys.h"
#include "gettime.h"
#include "gettext.h"
#define MY_CHECKPOS(a,b) \
if (v_pos.size() != 2) { \
errorstream<< "Invalid pos for element " << a << "specified: \"" \
@ -88,7 +86,6 @@ GUIFormSpecMenu::GUIFormSpecMenu(irr::IrrlichtDevice* dev,
m_listbox_doubleclick(false),
m_tooltip_element(NULL),
m_allowclose(true),
m_use_gettext(false),
m_lock(false)
{
current_keys_pending.key_down = false;
@ -379,9 +376,6 @@ void GUIFormSpecMenu::parseCheckbox(parserData* data,std::string element) {
std::wstring wlabel = narrow_to_wide(label.c_str());
if (m_use_gettext)
wlabel = wstrgettext(label);
FieldSpec spec = FieldSpec(
narrow_to_wide(name.c_str()),
L"",
@ -499,9 +493,6 @@ void GUIFormSpecMenu::parseButton(parserData* data,std::string element,std::stri
std::wstring wlabel = narrow_to_wide(label.c_str());
if (m_use_gettext)
wlabel = wstrgettext(label);
FieldSpec spec = FieldSpec(
narrow_to_wide(name.c_str()),
wlabel,
@ -609,7 +600,6 @@ void GUIFormSpecMenu::parseTextList(parserData* data,std::string element) {
std::wstring toadd =
narrow_to_wide(unescape_string(items[i]).c_str() + 7);
e->addItem(toadd.c_str());
irr::video::SColor toset;
@ -733,13 +723,6 @@ void GUIFormSpecMenu::parsePwdField(parserData* data,std::string element) {
std::wstring wlabel = narrow_to_wide(label.c_str());
if (m_use_gettext) {
if (label.length() > 1)
wlabel = wstrgettext(label);
else
wlabel = L"";
}
FieldSpec spec = FieldSpec(
narrow_to_wide(name.c_str()),
wlabel,
@ -812,13 +795,6 @@ void GUIFormSpecMenu::parseSimpleField(parserData* data,std::vector<std::string>
std::wstring wlabel = narrow_to_wide(label.c_str());
if (m_use_gettext) {
if (label.length() > 1)
wlabel = wstrgettext(label);
else
wlabel = L"";
}
FieldSpec spec = FieldSpec(
narrow_to_wide(name.c_str()),
wlabel,
@ -902,13 +878,6 @@ void GUIFormSpecMenu::parseTextArea(parserData* data,std::vector<std::string>& p
std::wstring wlabel = narrow_to_wide(label.c_str());
if (m_use_gettext) {
if (label.length() > 1)
wlabel = wstrgettext(label);
else
wlabel = L"";
}
FieldSpec spec = FieldSpec(
narrow_to_wide(name.c_str()),
wlabel,
@ -989,9 +958,6 @@ void GUIFormSpecMenu::parseLabel(parserData* data,std::string element) {
std::wstring wlabel = narrow_to_wide(text.c_str());
if (m_use_gettext)
wlabel = wstrgettext(text);
FieldSpec spec = FieldSpec(
L"",
wlabel,
@ -1026,12 +992,6 @@ void GUIFormSpecMenu::parseVertLabel(parserData* data,std::string element) {
text = unescape_string(text);
std::string label = "";
if (m_use_gettext) {
const char* toset = gettext(text.c_str());
text = std::string(toset);
}
for (unsigned int i=0; i < text.length(); i++) {
label += text.c_str()[i];
label += "\n";
@ -1098,9 +1058,6 @@ void GUIFormSpecMenu::parseImageButton(parserData* data,std::string element,std:
std::wstring wlabel = narrow_to_wide(label.c_str());
if (m_use_gettext)
wlabel = wstrgettext(label);
FieldSpec spec = FieldSpec(
narrow_to_wide(name.c_str()),
wlabel,
@ -1194,15 +1151,9 @@ void GUIFormSpecMenu::parseTabHeader(parserData* data,std::string element) {
for (unsigned int i=0; i< buttons.size(); i++) {
wchar_t* wbutton = 0;
if (m_use_gettext)
wbutton = wgettext(buttons[i].c_str());
else
wbutton = (wchar_t*) narrow_to_wide(buttons[i].c_str()).c_str();
wbutton = (wchar_t*) narrow_to_wide(buttons[i].c_str()).c_str();
e->addTab(wbutton,-1);
if (m_use_gettext)
delete[] wbutton;
}
if ((tab_index >= 0) &&

@ -206,10 +206,6 @@ public:
m_allowclose = value;
}
void useGettext(bool value) {
m_use_gettext = true;
}
void lockSize(bool lock,v2u32 basescreensize=v2u32(0,0)) {
m_lock = lock;
m_lockscreensize = basescreensize;
@ -282,7 +278,6 @@ protected:
gui::IGUIStaticText *m_tooltip_element;
bool m_allowclose;
bool m_use_gettext;
bool m_lock;
v2u32 m_lockscreensize;
private:

@ -980,6 +980,16 @@ int ModApiMainMenu::l_download_file(lua_State *L)
return 1;
}
/******************************************************************************/
int ModApiMainMenu::l_gettext(lua_State *L)
{
const char* str = luaL_checkstring(L, 1);
str = gettext(str);
lua_pushstring(L, str);
return 1;
}
/******************************************************************************/
void ModApiMainMenu::Initialize(lua_State *L, int top)
{
@ -1013,4 +1023,5 @@ void ModApiMainMenu::Initialize(lua_State *L, int top)
API_FCT(get_modstore_list);
API_FCT(sound_play);
API_FCT(sound_stop);
API_FCT(gettext);
}

@ -81,6 +81,8 @@ private:
static int l_sound_stop(lua_State *L);
static int l_gettext(lua_State *L);
//gui
static int l_show_keys_menu(lua_State *L);

@ -48,7 +48,7 @@ cd ..
# directory at the top level. You a recent enough xgettext that supports
# --package-name
potfile=po/minetest.pot
xgettext --package-name=minetest -kN_ -kwgettext -F -n -o $potfile src/*.cpp src/*.h
xgettext --package-name=minetest -kN_ -kwgettext -kfgettext -F -n -o $potfile src/*.cpp src/*.h builtin/*.lua
# Now iterate on all languages and create the po file if missing, or update it
# if it exists already