From 04161c0e9e809679f309ca56b972869178d0dbcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Fern=C3=A1ndez?= <975883+pazos@users.noreply.github.com> Date: Wed, 23 Oct 2024 10:43:40 +0200 Subject: [PATCH] translated deprecation reasons (#12636) Keep translated strings around on deprecation --- frontend/pluginloader.lua | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/frontend/pluginloader.lua b/frontend/pluginloader.lua index 3d063e990..3075a99a3 100644 --- a/frontend/pluginloader.lua +++ b/frontend/pluginloader.lua @@ -14,14 +14,38 @@ local OBSOLETE_PLUGINS = { storagestat = true, zsync = true, } + +local DEPRECATION_MESSAGES = { + remove = _("This plugin is unmaintained and will be removed soon."), + feature = _("The following features are unmaintained and will be removed soon:"), +} + +local function deprecationFmt(field) + local s + if type(field) == "table" then + local f1, f2 = DEPRECATION_MESSAGES[field[1]], field[2] + if not f2 then + s = string.format("%s", f1) + else + s = string.format("%s: %s", f1, f2) + end + end + if not s then + return nil, "" + end + return true, s +end + -- Deprecated plugins are still available, but show a hint about deprecation. local function getMenuTable(plugin) local t = {} t.name = plugin.name t.fullname = string.format("%s%s", plugin.fullname or plugin.name, plugin.deprecated and " (" .. _("outdated") .. ")" or "") + + local deprecated, message = deprecationFmt(plugin.deprecated) t.description = string.format("%s%s", plugin.description, - type(plugin.deprecated) == "string" and "\n\n" .. plugin.deprecated or "") + deprecated and "\n\n" .. message or "") return t end