From e5a5d5a672b41c36dce139d71fb087217ed532d4 Mon Sep 17 00:00:00 2001 From: Gregor Parzefall Date: Thu, 1 Jun 2023 20:35:40 +0200 Subject: [PATCH] Fix various cases of double-escaped error messages --- builtin/fstk/ui.lua | 4 ++-- builtin/mainmenu/dlg_contentstore.lua | 8 ++++---- builtin/mainmenu/dlg_create_world.lua | 4 ++-- builtin/mainmenu/dlg_delete_content.lua | 4 ++-- builtin/mainmenu/pkgmgr.lua | 12 ++++++------ builtin/mainmenu/tab_local.lua | 2 +- builtin/mainmenu/tests/pkgmgr_spec.lua | 2 +- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/builtin/fstk/ui.lua b/builtin/fstk/ui.lua index 13f9cbec2..a63cb2cd0 100644 --- a/builtin/fstk/ui.lua +++ b/builtin/fstk/ui.lua @@ -62,8 +62,8 @@ function ui.update() -- handle errors if gamedata ~= nil and gamedata.reconnect_requested then - local error_message = core.formspec_escape( - gamedata.errormessage or fgettext("")) + local error_message = core.formspec_escape(gamedata.errormessage) + or fgettext("") formspec = { "size[14,8]", "real_coordinates[true]", diff --git a/builtin/mainmenu/dlg_contentstore.lua b/builtin/mainmenu/dlg_contentstore.lua index 21b7ad457..e32da2501 100644 --- a/builtin/mainmenu/dlg_contentstore.lua +++ b/builtin/mainmenu/dlg_contentstore.lua @@ -89,7 +89,7 @@ local function download_and_extract(param) if filename == "" or not core.download_file(param.url, filename) then core.log("error", "Downloading " .. dump(param.url) .. " failed") return { - msg = fgettext("Failed to download \"$1\"", package.title) + msg = fgettext_ne("Failed to download \"$1\"", package.title) } end @@ -105,7 +105,7 @@ local function download_and_extract(param) os.remove(filename) if not tempfolder then 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 @@ -129,7 +129,7 @@ local function start_install(package, reason) local path, msg = pkgmgr.install_dir(package.type, result.path, package.name, package.path) core.delete_dir(result.path) 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 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 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 end end diff --git a/builtin/mainmenu/dlg_create_world.lua b/builtin/mainmenu/dlg_create_world.lua index eb7a596a0..18d4c07a6 100644 --- a/builtin/mainmenu/dlg_create_world.lua +++ b/builtin/mainmenu/dlg_create_world.lua @@ -363,7 +363,7 @@ local function create_world_buttonhandler(this, fields) local message if game == nil then - message = fgettext("No game selected") + message = fgettext_ne("No game selected") end if message == nil then @@ -382,7 +382,7 @@ local function create_world_buttonhandler(this, fields) end 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 diff --git a/builtin/mainmenu/dlg_delete_content.lua b/builtin/mainmenu/dlg_delete_content.lua index 4463825f7..1a6178acc 100644 --- a/builtin/mainmenu/dlg_delete_content.lua +++ b/builtin/mainmenu/dlg_delete_content.lua @@ -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_texturepath() 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 if this.data.content.type == "game" then @@ -43,7 +43,7 @@ local function delete_content_buttonhandler(this, fields) pkgmgr.refresh_globals() end 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 this:delete() return true diff --git a/builtin/mainmenu/pkgmgr.lua b/builtin/mainmenu/pkgmgr.lua index 51f635962..76aa02fa1 100644 --- a/builtin/mainmenu/pkgmgr.lua +++ b/builtin/mainmenu/pkgmgr.lua @@ -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 -- it's correct for now. 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 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) if not core.copy_dir(from, targetpath, false) then return nil, - fgettext("Failed to install $1 to $2", basename, targetpath) + fgettext_ne("Failed to install $1 to $2", basename, targetpath) end return targetpath, nil 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 -- Check type 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 -- Set targetpath if not predetermined @@ -575,7 +575,7 @@ function pkgmgr.install_dir(expected_type, path, basename, targetpath) targetpath = content_path .. DIR_DELIM .. basename else 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 @@ -583,7 +583,7 @@ function pkgmgr.install_dir(expected_type, path, basename, targetpath) core.delete_dir(targetpath) if not core.copy_dir(basefolder.path, targetpath, false) then return nil, - fgettext("Failed to install $1 to $2", basename, targetpath) + fgettext_ne("Failed to install $1 to $2", basename, targetpath) end if basefolder.type == "game" then diff --git a/builtin/mainmenu/tab_local.lua b/builtin/mainmenu/tab_local.lua index eed373428..de121e65b 100644 --- a/builtin/mainmenu/tab_local.lua +++ b/builtin/mainmenu/tab_local.lua @@ -284,7 +284,7 @@ local function main_button_handler(this, fields, name, tabdata) if selected == nil or gamedata.selected_world == 0 then gamedata.errormessage = - fgettext("No world created or selected!") + fgettext_ne("No world created or selected!") return true end diff --git a/builtin/mainmenu/tests/pkgmgr_spec.lua b/builtin/mainmenu/tests/pkgmgr_spec.lua index 558fae9fb..bf3ffb77c 100644 --- a/builtin/mainmenu/tests/pkgmgr_spec.lua +++ b/builtin/mainmenu/tests/pkgmgr_spec.lua @@ -52,7 +52,7 @@ local function reset() function core.get_gamepath() return games_dir end - function env.fgettext(fmt, ...) + function env.fgettext_ne(fmt, ...) return fmt end