1
0
mirror of https://github.com/moparisthebest/minetest synced 2024-12-22 15:48:48 -05:00

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

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

View File

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

View File

@ -167,6 +167,13 @@ engine.file_open_dialog(formname,caption)
^ returns nil or selected file/folder ^ returns nil or selected file/folder
Helpers: 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={}) dump(obj, dumped={})
^ Return object serialized as a string ^ Return object serialized as a string
string:split(separator) string:split(separator)

View File

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

View File

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

View File

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

View File

@ -980,6 +980,16 @@ int ModApiMainMenu::l_download_file(lua_State *L)
return 1; 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) 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(get_modstore_list);
API_FCT(sound_play); API_FCT(sound_play);
API_FCT(sound_stop); API_FCT(sound_stop);
API_FCT(gettext);
} }

View File

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

View File

@ -48,7 +48,7 @@ cd ..
# directory at the top level. You a recent enough xgettext that supports # directory at the top level. You a recent enough xgettext that supports
# --package-name # --package-name
potfile=po/minetest.pot 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 # Now iterate on all languages and create the po file if missing, or update it
# if it exists already # if it exists already