Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load qt5 translations #1594

Merged
merged 3 commits into from
Oct 7, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Load qt5 translations
  • Loading branch information
iakov committed Oct 3, 2022
commit 3eb8167d59a3e8ee7fb1d693c535e131c7ce0e0a
12 changes: 12 additions & 0 deletions qrgui/mainWindow/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include <QtCore/QtPlugin>
#include <QtCore/QTranslator>
#include <QtCore/QLibraryInfo>
#include <QtCore/QDirIterator>
#include <QtWidgets/QApplication>
#include <QStyleFactory>
Expand Down Expand Up @@ -49,6 +50,17 @@ void loadTranslators(const QString &locale)
QCoreApplication::installTranslator(translator);
}
}

/// Load Qt's system translations
auto *t = new QTranslator();
QDirIterator files(QLibraryInfo::location(QLibraryInfo::TranslationsPath), {"*_"+locale+".qm"}, QDir::Files);
while(files.hasNext()) {
const auto &f = files.next();
if (!t->load(f)) {
QLOG_ERROR() << "Failed to load translation file" << f;
}
}
QCoreApplication::installTranslator(t);
}

void setDefaultLocale(bool localizationDisabled)
Expand Down