Merge pull request #6332 from nextcloud/bugfix/missingTranslations

Bugfix/missing translations in AppImage
This commit is contained in:
Matthieu Gallien 2024-01-05 15:58:28 +01:00 коммит произвёл GitHub
Родитель 4714e01477 7bff44daa1
Коммит 053202e881
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 16 добавлений и 2 удалений

Просмотреть файл

@ -113,7 +113,11 @@ namespace {
#elif defined(Q_OS_MAC) #elif defined(Q_OS_MAC)
return QApplication::applicationDirPath() + QLatin1String("/../Resources/Translations"); // path defaults to app dir. return QApplication::applicationDirPath() + QLatin1String("/../Resources/Translations"); // path defaults to app dir.
#elif defined(Q_OS_UNIX) #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 #endif
} }
} }
@ -961,8 +965,14 @@ void Application::setupTranslations()
for (QString lang : qAsConst(uiLanguages)) { for (QString lang : qAsConst(uiLanguages)) {
lang.replace(QLatin1Char('-'), QLatin1Char('_')); // work around QTBUG-25973 lang.replace(QLatin1Char('-'), QLatin1Char('_')); // work around QTBUG-25973
lang = substLang(lang); 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; 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"))) { if (translator->load(trFile, trPath) || lang.startsWith(QLatin1String("en"))) {
// Permissive approach: Qt and keychain translations // Permissive approach: Qt and keychain translations
// may be missing, but Qt translations must be there in order // may be missing, but Qt translations must be there in order
@ -992,6 +1002,10 @@ void Application::setupTranslations()
if (!qtkeychainTranslator->isEmpty()) if (!qtkeychainTranslator->isEmpty())
installTranslator(qtkeychainTranslator); installTranslator(qtkeychainTranslator);
break; 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()) { if (property("ui_lang").isNull()) {
setProperty("ui_lang", "C"); setProperty("ui_lang", "C");