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 Nils Dagsson Moskopp
parent e9cadb712e
commit 243ff49bf2
Signed by: erle
GPG Key ID: A3BC671C35191080
5 changed files with 218 additions and 165 deletions

View File

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

View File

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

View File

@ -85,6 +85,17 @@ function string:split(sep)
return fields return fields
end 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() function string:trim()
return (self:gsub("^%s*(.-)%s*$", "%1")) return (self:gsub("^%s*(.-)%s*$", "%1"))
@ -92,8 +103,6 @@ end
assert(string.trim("\n \t\tfoo bar\t ") == "foo bar") assert(string.trim("\n \t\tfoo bar\t ") == "foo bar")
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
function math.hypot(x, y) function math.hypot(x, y)
local t local t
@ -209,6 +218,29 @@ if engine ~= nil then
return nil return nil
end 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 end
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- core only fct -- core only fct

View File

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

View File

@ -180,8 +180,7 @@ end
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
function modstore.getmodlist(list) function modstore.getmodlist(list)
local retval = "" local retval = ""
retval = retval .. "label[10,-0.4;Page " .. (list.page +1) .. retval = retval .. "label[10,-0.4;" .. fgettext("Page $1 of $2", list.page+1, list.pagecount) .. "]"
" of " .. list.pagecount .. "]"
retval = retval .. "button[11.6,-0.1;0.5,0.5;btn_modstore_page_up;^]" 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]" 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) .. ";]" engine.formspec_escape(details.description) .. ";]"
--rating --rating
local ratingy = screenshot_ypos + 0.6 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 --install button
local buttony = screenshot_ypos + 1.2 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 .. ";" retval = retval .."button[9.6," .. buttony .. ";2,0.5;btn_install_mod_" .. buttonnumber .. ";"
if modmgr.mod_exists(details.basename) then if modmgr.mod_exists(details.basename) then
retval = retval .. "re-Install]" retval = retval .. fgettext("re-Install") .."]"
else else
retval = retval .. "Install]" retval = retval .. fgettext("Install") .."]"
end end
end end
end end