Escape " in generated settings_translation_file.cpp
[oweals/minetest.git] / builtin / mainmenu / common.lua
index 5cd16a9eab6ea9111e6307e4cf28b582bb19cfb6..f4020aaaf00c5adc46f079aff4d1a424fe8234ca 100644 (file)
@@ -224,10 +224,10 @@ function menu_handle_key_up_down(fields,textlist,settingname)
 
                        configure_selected_world_params(newidx)
                end
-               
+
                return true
        end
-       
+
        return false
 end
 
@@ -237,7 +237,7 @@ function asyncOnlineFavourites()
        if not menudata.public_known then
                menudata.public_known = {{
                        name = fgettext("Loading..."),
-                       description = fgettext("Try reenabling public serverlist and check your internet connection.")
+                       description = fgettext_ne("Try reenabling public serverlist and check your internet connection.")
                }}
        end
        menudata.favorites = menudata.public_known
@@ -262,39 +262,52 @@ end
 --------------------------------------------------------------------------------
 function text2textlist(xpos,ypos,width,height,tl_name,textlen,text,transparency)
        local textlines = core.splittext(text,textlen)
-       
+
        local retval = "textlist[" .. xpos .. "," .. ypos .. ";"
                                                                .. width .. "," .. height .. ";"
                                                                .. tl_name .. ";"
-       
+
        for i=1, #textlines, 1 do
                textlines[i] = textlines[i]:gsub("\r","")
                retval = retval .. core.formspec_escape(textlines[i]) .. ","
        end
-       
+
        retval = retval .. ";0;"
-       
+
        if transparency then
                retval = retval .. "true"
        end
-       
+
        retval = retval .. "]"
 
        return retval
 end
 
 --------------------------------------------------------------------------------
-function is_server_protocol_compat(proto_min, proto_max)
-       return not ((min_supp_proto > (proto_max or 24)) or (max_supp_proto < (proto_min or 13)))
+function is_server_protocol_compat(server_proto_min, server_proto_max)
+       return not ((min_supp_proto > (server_proto_max or 24)) or (max_supp_proto < (server_proto_min or 13)))
 end
 --------------------------------------------------------------------------------
-function is_server_protocol_compat_or_error(proto_min, proto_max)
-       if not is_server_protocol_compat(proto_min, proto_max) then
-               gamedata.errormessage = fgettext_ne("Protocol version mismatch, server " ..
-                       ((proto_min ~= proto_max) and "supports protocols between $1 and $2" or "enforces protocol version $1") ..
-                       ", we " ..
-                       ((min_supp_proto ~= max_supp_proto) and "support protocols between version $3 and $4." or "only support protocol version $3"),
-                       proto_min or 13, proto_max or 24, min_supp_proto, max_supp_proto)
+function is_server_protocol_compat_or_error(server_proto_min, server_proto_max)
+       if not is_server_protocol_compat(server_proto_min, server_proto_max) then
+               local server_prot_ver_info
+               local client_prot_ver_info
+               if server_proto_min ~= server_proto_max then
+                       server_prot_ver_info = fgettext_ne("Server supports protocol versions between $1 and $2. ",
+                               server_proto_min or 13, server_proto_max or 24)
+               else
+                       server_prot_ver_info = fgettext_ne("Server enforces protocol version $1. ",
+                               server_proto_min or 13)
+               end
+               if min_supp_proto ~= max_supp_proto then
+                       client_prot_ver_info= fgettext_ne("We support protocol versions between version $1 and $2.",
+                               min_supp_proto, max_supp_proto)
+               else
+                       client_prot_ver_info = fgettext_ne("We only support protocol version $1.", min_supp_proto)
+               end
+               gamedata.errormessage = fgettext_ne("Protocol version mismatch. ")
+                       .. server_prot_ver_info
+                       .. client_prot_ver_info
                return false
        end
 
@@ -311,7 +324,8 @@ function menu_worldmt(selected, setting, value)
                        if not world_conf:write() then
                                core.log("error", "Failed to write world config file")
                        end
-                       return world_conf:set(setting, value)
+                       world_conf:set(setting, value)
+                       world_conf:write()
                else
                        return world_conf:get(setting)
                end
@@ -321,7 +335,7 @@ function menu_worldmt(selected, setting, value)
 end
 
 function menu_worldmt_legacy(selected)
-       local modes_names = {"creative_mode", "enable_damage"}
+       local modes_names = {"creative_mode", "enable_damage", "server_announce"}
        for _, mode_name in pairs(modes_names) do
                local mode_val = menu_worldmt(selected, mode_name)
                if mode_val ~= nil then