Skip to content

Commit

Permalink
fix: linglong app load qt translations failed
Browse files Browse the repository at this point in the history
qt translations fallback to GenericDataLocation paths
  • Loading branch information
kegechen committed Dec 3, 2024
1 parent 79440d4 commit f5a7cc2
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/kernel/dguiapplicationhelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1682,17 +1682,24 @@ bool DGuiApplicationHelper::loadTranslator(const QList<QLocale> &localeFallback)
#else
auto qTranslationsPath = QLibraryInfo::path(QLibraryInfo::TranslationsPath);
#endif
loadTranslator("qt", {qTranslationsPath}, localeFallback);
loadTranslator("qtbase", {qTranslationsPath}, localeFallback);

DCORE_USE_NAMESPACE
QList<QString> translateDirs;
auto appName = qApp->applicationName();
//("/home/user/.local/share", "/usr/local/share", "/usr/share")
auto dataDirs = DStandardPaths::standardLocations(QStandardPaths::GenericDataLocation);
QList<QString> qtranslateDirs = { qTranslationsPath };
for (const auto &path : dataDirs) {
DPathBuf pathBuf(path);
qtranslateDirs << (pathBuf / "qt" QT_STRINGIFY(QT_VERSION_MAJOR) / "translations").toString();
}

loadTranslator("qt", qtranslateDirs, localeFallback);
loadTranslator("qtbase", qtranslateDirs, localeFallback);

QList<QString> translateDirs;
auto appName = qApp->applicationName();
for (const auto &path : dataDirs) {
DPathBuf DPathBuf(path);
translateDirs << (DPathBuf / appName / "translations").toString();
DPathBuf pathBuf(path);
translateDirs << (pathBuf / appName / "translations").toString();
}

// ${translateDir}/${appName}_${localeName}.qm
Expand Down

0 comments on commit f5a7cc2

Please sign in to comment.