Fix translation loading.
continuous-integration/drone/push Build is passing Details

https://www.kdab.com/fixing-a-common-antipattern-when-loading-translations-in-qt/
This commit is contained in:
tastytea 2020-07-09 13:22:17 +02:00
parent b19e8b233a
commit 3a8b8c715a
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
1 changed files with 9 additions and 6 deletions

View File

@ -1,5 +1,5 @@
/* This file is part of whyblocked. /* This file is part of whyblocked.
* Copyright © 2019 tastytea <tastytea@tastytea.de> * Copyright © 2019, 2020 tastytea <tastytea@tastytea.de>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -14,21 +14,24 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <QTranslator>
#include <QLibraryInfo>
#include "mainwindow.hpp" #include "mainwindow.hpp"
#include <QLibraryInfo>
#include <QLocale>
#include <QTranslator>
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
QApplication app(argc, argv); QApplication app(argc, argv);
QCoreApplication::setApplicationName("Whyblocked"); QCoreApplication::setApplicationName("Whyblocked");
QTranslator qtTranslator; QTranslator qtTranslator;
qtTranslator.load("qt_" + QLocale::system().name(), qtTranslator.load(QLocale(), "qt", "_",
QLibraryInfo::location(QLibraryInfo::TranslationsPath)); QLibraryInfo::location(QLibraryInfo::TranslationsPath));
app.installTranslator(&qtTranslator); app.installTranslator(&qtTranslator);
QTranslator appTranslator; QTranslator appTranslator;
appTranslator.load("whyblocked_" + QLocale::system().name(), appTranslator.load(QLocale(), "whyblocked", "_",
QLibraryInfo::location(QLibraryInfo::TranslationsPath)); QLibraryInfo::location(QLibraryInfo::TranslationsPath));
app.installTranslator(&appTranslator); app.installTranslator(&appTranslator);