Fix various cases of double-escaped error messages

This commit is contained in:
Gregor Parzefall 2023-06-01 20:35:40 +02:00 committed by sfan5
parent 29b7aea38b
commit e5a5d5a672
7 changed files with 18 additions and 18 deletions

@ -62,8 +62,8 @@ function ui.update()
-- handle errors -- handle errors
if gamedata ~= nil and gamedata.reconnect_requested then if gamedata ~= nil and gamedata.reconnect_requested then
local error_message = core.formspec_escape( local error_message = core.formspec_escape(gamedata.errormessage)
gamedata.errormessage or fgettext("<none available>")) or fgettext("<none available>")
formspec = { formspec = {
"size[14,8]", "size[14,8]",
"real_coordinates[true]", "real_coordinates[true]",

@ -89,7 +89,7 @@ local function download_and_extract(param)
if filename == "" or not core.download_file(param.url, filename) then if filename == "" or not core.download_file(param.url, filename) then
core.log("error", "Downloading " .. dump(param.url) .. " failed") core.log("error", "Downloading " .. dump(param.url) .. " failed")
return { return {
msg = fgettext("Failed to download \"$1\"", package.title) msg = fgettext_ne("Failed to download \"$1\"", package.title)
} }
end end
@ -105,7 +105,7 @@ local function download_and_extract(param)
os.remove(filename) os.remove(filename)
if not tempfolder then if not tempfolder then
return { return {
msg = fgettext("Failed to extract \"$1\" (unsupported file type or broken archive)", package.title), msg = fgettext_ne("Failed to extract \"$1\" (unsupported file type or broken archive)", package.title),
} }
end end
@ -129,7 +129,7 @@ local function start_install(package, reason)
local path, msg = pkgmgr.install_dir(package.type, result.path, package.name, package.path) local path, msg = pkgmgr.install_dir(package.type, result.path, package.name, package.path)
core.delete_dir(result.path) core.delete_dir(result.path)
if not path then if not path then
gamedata.errormessage = fgettext("Error installing \"$1\": $2", package.title, msg) gamedata.errormessage = fgettext_ne("Error installing \"$1\": $2", package.title, msg)
else else
core.log("action", "Installed package to " .. path) core.log("action", "Installed package to " .. path)
@ -184,7 +184,7 @@ local function start_install(package, reason)
if not core.handle_async(download_and_extract, params, callback) then if not core.handle_async(download_and_extract, params, callback) then
core.log("error", "ERROR: async event failed") core.log("error", "ERROR: async event failed")
gamedata.errormessage = fgettext("Failed to download $1", package.name) gamedata.errormessage = fgettext_ne("Failed to download $1", package.name)
return return
end end
end end

@ -363,7 +363,7 @@ local function create_world_buttonhandler(this, fields)
local message local message
if game == nil then if game == nil then
message = fgettext("No game selected") message = fgettext_ne("No game selected")
end end
if message == nil then if message == nil then
@ -382,7 +382,7 @@ local function create_world_buttonhandler(this, fields)
end end
if menudata.worldlist:uid_exists_raw(worldname) then if menudata.worldlist:uid_exists_raw(worldname) then
message = fgettext("A world named \"$1\" already exists", worldname) message = fgettext_ne("A world named \"$1\" already exists", worldname)
end end
end end

@ -34,7 +34,7 @@ local function delete_content_buttonhandler(this, fields)
this.data.content.path ~= core.get_gamepath() and this.data.content.path ~= core.get_gamepath() and
this.data.content.path ~= core.get_texturepath() then this.data.content.path ~= core.get_texturepath() then
if not core.delete_dir(this.data.content.path) then if not core.delete_dir(this.data.content.path) then
gamedata.errormessage = fgettext("pkgmgr: failed to delete \"$1\"", this.data.content.path) gamedata.errormessage = fgettext_ne("pkgmgr: failed to delete \"$1\"", this.data.content.path)
end end
if this.data.content.type == "game" then if this.data.content.type == "game" then
@ -43,7 +43,7 @@ local function delete_content_buttonhandler(this, fields)
pkgmgr.refresh_globals() pkgmgr.refresh_globals()
end end
else else
gamedata.errormessage = fgettext("pkgmgr: invalid path \"$1\"", this.data.content.path) gamedata.errormessage = fgettext_ne("pkgmgr: invalid path \"$1\"", this.data.content.path)
end end
this:delete() this:delete()
return true return true

@ -534,7 +534,7 @@ function pkgmgr.install_dir(expected_type, path, basename, targetpath)
-- There's no good way to detect a texture pack, so let's just assume -- There's no good way to detect a texture pack, so let's just assume
-- it's correct for now. -- it's correct for now.
if basefolder and basefolder.type ~= "invalid" and basefolder.type ~= "txp" then if basefolder and basefolder.type ~= "invalid" and basefolder.type ~= "txp" then
return nil, fgettext("Unable to install a $1 as a texture pack", basefolder.type) return nil, fgettext_ne("Unable to install a $1 as a texture pack", basefolder.type)
end end
local from = basefolder and basefolder.path or path local from = basefolder and basefolder.path or path
@ -544,17 +544,17 @@ function pkgmgr.install_dir(expected_type, path, basename, targetpath)
core.delete_dir(targetpath) core.delete_dir(targetpath)
if not core.copy_dir(from, targetpath, false) then if not core.copy_dir(from, targetpath, false) then
return nil, return nil,
fgettext("Failed to install $1 to $2", basename, targetpath) fgettext_ne("Failed to install $1 to $2", basename, targetpath)
end end
return targetpath, nil return targetpath, nil
elseif not basefolder then elseif not basefolder then
return nil, fgettext("Unable to find a valid mod, modpack, or game") return nil, fgettext_ne("Unable to find a valid mod, modpack, or game")
end end
-- Check type -- Check type
if basefolder.type ~= expected_type and (basefolder.type ~= "modpack" or expected_type ~= "mod") then if basefolder.type ~= expected_type and (basefolder.type ~= "modpack" or expected_type ~= "mod") then
return nil, fgettext("Unable to install a $1 as a $2", basefolder.type, expected_type) return nil, fgettext_ne("Unable to install a $1 as a $2", basefolder.type, expected_type)
end end
-- Set targetpath if not predetermined -- Set targetpath if not predetermined
@ -575,7 +575,7 @@ function pkgmgr.install_dir(expected_type, path, basename, targetpath)
targetpath = content_path .. DIR_DELIM .. basename targetpath = content_path .. DIR_DELIM .. basename
else else
return nil, return nil,
fgettext("Install: Unable to find suitable folder name for $1", path) fgettext_ne("Install: Unable to find suitable folder name for $1", path)
end end
end end
@ -583,7 +583,7 @@ function pkgmgr.install_dir(expected_type, path, basename, targetpath)
core.delete_dir(targetpath) core.delete_dir(targetpath)
if not core.copy_dir(basefolder.path, targetpath, false) then if not core.copy_dir(basefolder.path, targetpath, false) then
return nil, return nil,
fgettext("Failed to install $1 to $2", basename, targetpath) fgettext_ne("Failed to install $1 to $2", basename, targetpath)
end end
if basefolder.type == "game" then if basefolder.type == "game" then

@ -284,7 +284,7 @@ local function main_button_handler(this, fields, name, tabdata)
if selected == nil or gamedata.selected_world == 0 then if selected == nil or gamedata.selected_world == 0 then
gamedata.errormessage = gamedata.errormessage =
fgettext("No world created or selected!") fgettext_ne("No world created or selected!")
return true return true
end end

@ -52,7 +52,7 @@ local function reset()
function core.get_gamepath() function core.get_gamepath()
return games_dir return games_dir
end end
function env.fgettext(fmt, ...) function env.fgettext_ne(fmt, ...)
return fmt return fmt
end end