Fix translation loading.
https://www.kdab.com/fixing-a-common-antipattern-when-loading-translations-in-qt/develop
parent
b19e8b233a
commit
3a8b8c715a
|
@ -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);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue