Skip to content

Commit

Permalink
Merge pull request #6334 from nextcloud/backport/6332/stable-3.10
Browse files Browse the repository at this point in the history
[stable-3.10] Bugfix/missing translations in AppImage
  • Loading branch information
mgallien authored Jan 8, 2024
2 parents 5820c9b + 13f9051 commit fce65c6
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/gui/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,11 @@ namespace {
#elif defined(Q_OS_MAC)
return QApplication::applicationDirPath() + QLatin1String("/../Resources/Translations"); // path defaults to app dir.
#elif defined(Q_OS_UNIX)
return QString::fromLatin1(SHAREDIR "/" APPLICATION_EXECUTABLE "/i18n/");
if (qEnvironmentVariableIsSet("APPIMAGE")) {
return QApplication::applicationDirPath() + QLatin1String("/../share/" APPLICATION_EXECUTABLE "/i18n/");
} else {
return QString::fromLatin1(SHAREDIR "/" APPLICATION_EXECUTABLE "/i18n/");
}
#endif
}
}
Expand Down Expand Up @@ -961,8 +965,14 @@ void Application::setupTranslations()
for (QString lang : qAsConst(uiLanguages)) {
lang.replace(QLatin1Char('-'), QLatin1Char('_')); // work around QTBUG-25973
lang = substLang(lang);
const QString trPath = applicationTrPath();
const auto trPath = applicationTrPath();
const auto trFolder = QDir{trPath};
if (!trFolder.exists()) {
qCWarning(lcApplication()) << trPath << "folder containing translations is missing. Impossible to load translations";
break;
}
const QString trFile = QLatin1String("client_") + lang;
qCDebug(lcApplication()) << "trying to load" << lang << "in" << trFile << "from" << trPath;
if (translator->load(trFile, trPath) || lang.startsWith(QLatin1String("en"))) {
// Permissive approach: Qt and keychain translations
// may be missing, but Qt translations must be there in order
Expand Down Expand Up @@ -992,6 +1002,10 @@ void Application::setupTranslations()
if (!qtkeychainTranslator->isEmpty())
installTranslator(qtkeychainTranslator);
break;
} else {
qCWarning(lcApplication()) << "translation catalog failed to load";
const auto folderContent = trFolder.entryList();
qCDebug(lcApplication()) << "folder content" << folderContent.join(QStringLiteral(", "));
}
if (property("ui_lang").isNull()) {
setProperty("ui_lang", "C");
Expand Down

0 comments on commit fce65c6

Please sign in to comment.