Commit d6d13d38 authored by Nicolas Fella's avatar Nicolas Fella
Browse files

Fix translating error messages from helper

Regular i18n does not seem to work for strings in the helper process, presumably due to it being run with elevated priviledges.

Instead use the lazy variant to only extract the strings and call i18n later when we are not in the helper any more

BUG: 441726
parent c0160bdf
......@@ -21,6 +21,7 @@
#include <KArchive>
#include <KConfig>
#include <KConfigGroup>
#include <KLazyLocalizedString>
#include <KLocalizedString>
#include <KTar>
#include <KUser>
......@@ -367,13 +368,13 @@ ActionReply SddmAuthHelper::installtheme(const QVariantMap &args)
archive.reset(new KTar(filePath));
} else {
auto e = ActionReply::HelperErrorReply();
e.setErrorDescription(i18n("Invalid theme package"));
e.setErrorDescription(kli18n("Invalid theme package").untranslatedText());
return e;
}
if (!archive->open(QIODevice::ReadOnly)) {
auto e = ActionReply::HelperErrorReply();
e.setErrorDescription(i18n("Could not open file"));
e.setErrorDescription(kli18n("Could not open file").untranslatedText());
return e;
}
......@@ -389,14 +390,14 @@ ActionReply SddmAuthHelper::installtheme(const QVariantMap &args)
auto entry = directory->entry(name);
if (!entry->isDirectory()) {
auto e = ActionReply::HelperErrorReply();
e.setErrorDescription(i18n("Invalid theme package"));
e.setErrorDescription(kli18n("Invalid theme package").untranslatedText());
return e;
}
auto subDirectory = static_cast<const KArchiveDirectory *>(entry);
auto metadataFile = subDirectory->file(QStringLiteral("metadata.desktop"));
if (!metadataFile || !metadataFile->data().contains("[SddmGreeterTheme]")) {
auto e = ActionReply::HelperErrorReply();
e.setErrorDescription(i18n("Invalid theme package"));
e.setErrorDescription(kli18n("Invalid theme package").untranslatedText());
return e;
}
installedPaths.append(themesBaseDir + QLatin1Char('/') + name);
......@@ -404,7 +405,7 @@ ActionReply SddmAuthHelper::installtheme(const QVariantMap &args)
if (!directory->copyTo(themesBaseDir)) {
auto e = ActionReply::HelperErrorReply();
e.setErrorDescription(i18n("Could not decompress archive"));
e.setErrorDescription(kli18n("Could not decompress archive").untranslatedText());
return e;
}
......
......@@ -26,8 +26,8 @@ KCM.GridViewKCM {
Connections {
target: kcm
function onErrorOccured(message) {
errorMessage.text = message;
function onErrorOccured(untranslatedMessage) {
errorMessage.text = i18n(untranslatedMessage);
errorMessage.visible = message.length > 0
}
......
......@@ -35,7 +35,7 @@ public:
public Q_SLOTS:
void save() override;
Q_SIGNALS:
void errorOccured(const QString &message);
void errorOccured(const QString &untranslatedMessage);
void syncSuccessful();
void resetSyncedDataSuccessful();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment