From 54e384e68eb69efa36714917b4f26bcb600f4a6a Mon Sep 17 00:00:00 2001 From: Nicolas Fella Date: Wed, 4 Jan 2023 14:53:33 +0100 Subject: [PATCH] Enable scripted effects to load config translations from the kpackage By default translations are loaded from /usr/share/locale. This works fine for builtin effects since we install our translations there. However, it doesn't work for third-party scripted effects. They only provide a kpackage and can't install anything to /usr/share/. This patch allows them to ship translations in contents/locale/$language/LC_MESSAGES/$domain.mo, where $domain is the X-KWin-Config-TranslationDomain metadata value This matches what Plasma does for applets since https://phabricator.kde.org/D5209 CCBUG: 317338 --- src/scripting/genericscriptedconfig.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/scripting/genericscriptedconfig.cpp b/src/scripting/genericscriptedconfig.cpp index 0811066afa..6686eec277 100644 --- a/src/scripting/genericscriptedconfig.cpp +++ b/src/scripting/genericscriptedconfig.cpp @@ -97,6 +97,11 @@ void GenericScriptedConfig::createUi() return; } + const QString localePath = packageRoot + QLatin1String("/contents/locale"); + if (QFileInfo::exists(localePath)) { + KLocalizedString::addDomainLocaleDir(metaData.value("X-KWin-Config-TranslationDomain").toUtf8(), localePath); + } + QFile xmlFile(kconfigXTFile); KConfigGroup cg = configGroup(); KConfigLoader *configLoader = new KConfigLoader(cg, &xmlFile, this);