translation loader + qm files added

This commit is contained in:
Rafael 2016-03-23 09:10:46 +01:00
parent 597ef4f051
commit 516765b513
5 changed files with 154 additions and 3 deletions

7
app.qrc Executable file
View File

@ -0,0 +1,7 @@
<RCC>
<qresource prefix="/tr">
<file>gta5sync_de.qm</file>
<file>qt_de.qm</file>
<file>qtbase_de.qm</file>
</qresource>
</RCC>

View File

@ -25,7 +25,7 @@ TARGET = gta5sync
TEMPLATE = app
SOURCES += main.cpp\
SOURCES += main.cpp \
SnapmaticPicture.cpp \
PictureDialog.cpp \
ProfileDatabase.cpp \
@ -58,10 +58,10 @@ FORMS += \
TRANSLATIONS += \
gta5sync_de.ts
RESOURCES +=
RESOURCES += \
app.qrc
OTHER_FILES += \
gta5sync_de.qm \
app.rc
win32: RC_FILE += app.rc

144
main.cpp
View File

@ -26,6 +26,7 @@
#include "SavegameData.h"
#include <QApplication>
#include <QStringList>
#include <QTranslator>
#include <QFileInfo>
#include <QObject>
#include <QString>
@ -38,6 +39,148 @@ int main(int argc, char *argv[])
a.setApplicationName("gta5sync");
a.setApplicationVersion("1.0.0");
QSettings settings("Syping Gaming Team", "gtasync");
settings.beginGroup("Interface");
QString language = settings.value("Language","System").toString();
settings.endGroup();
// Translate pre values
bool trsf = false;
bool svlp = false;
// Start internal translate loading
QTranslator appTranslator;
if (language == "System" || language.trimmed() == "")
{
QString languageName = QLocale::system().name();
QStringList langList = languageName.split("_");
if (langList.length() >= 1)
{
if (QFile::exists(":/tr/gta5sync_" + langList.at(0) + ".qm"))
{
if (!appTranslator.load(":/tr/gta5sync_" + langList.at(0) + ".qm"))
{
if (langList.at(0) != "en")
{
if (svlp) {trsf = true;}
}
}
}
else
{
if (langList.at(0) != "en")
{
if (svlp) {trsf = true;}
}
}
}
}
else
{
QString languageName = language;
QStringList langList = languageName.split("_");
if (langList.length() >= 1)
{
if (QFile::exists(":/tr/gta5sync_" + langList.at(0) + ".qm"))
{
appTranslator.load(":/tr/gta5sync_" + langList.at(0) + ".qm");
}
}
}
if (trsf)
{
QString languageName = QLocale::system().name();
QStringList langList = languageName.split("_");
if (langList.length() >= 1)
{
if (QFile::exists(":/tr/gta5sync_" + langList.at(0) + ".qm"))
{
appTranslator.load(":/tr/gta5sync_" + langList.at(0) + ".qm");
}
}
}
a.installTranslator(&appTranslator);
#ifdef QT5_MODE
QTranslator qtTranslator1;
if (language == "System" || language.trimmed() == "")
{
QString languageName = QLocale::system().name();
QStringList langList = languageName.split("_");
if (langList.length() >= 1)
{
if (QFile::exists(":/tr/qtbase_" + langList.at(0) + ".qm"))
{
qtTranslator1.load(":/tr/qtbase_" + langList.at(0) + ".qm");
}
}
}
else
{
QString languageName = language;
QStringList langList = languageName.split("_");
if (langList.length() >= 1)
{
if (QFile::exists(":/tr/qtbase_" + langList.at(0) + ".qm"))
{
qtTranslator1.load(":/tr/qtbase_" + langList.at(0) + ".qm");
}
}
}
if (trsf)
{
QString languageName = QLocale::system().name();
QStringList langList = languageName.split("_");
if (langList.length() >= 1)
{
if (QFile::exists(":/tr/qtbase_" + langList.at(0) + ".qm"))
{
qtTranslator1.load(":/tr/qtbase_" + langList.at(0) + ".qm");
}
}
}
a.installTranslator(&qtTranslator1);
#else
QTranslator qtTranslator1;
if (language == "System" || language.trimmed() == "")
{
QString languageName = QLocale::system().name();
QStringList langList = languageName.split("_");
if (langList.length() >= 1)
{
if (QFile::exists(":/tr/qt_" + langList.at(0) + ".qm"))
{
qtTranslator1.load(":/tr/qt_" + langList.at(0) + ".qm");
}
}
}
else
{
QString languageName = language;
QStringList langList = languageName.split("_");
if (langList.length() >= 1)
{
if (QFile::exists(":/tr/qt_" + langList.at(0) + ".qm"))
{
qtTranslator1.load(":/tr/qt_" + langList.at(0) + ".qm");
}
}
}
if (trsf)
{
QString languageName = QLocale::system().name();
QStringList langList = languageName.split("_");
if (langList.length() >= 1)
{
if (QFile::exists(":/tr/qt_" + langList.at(0) + ".qm"))
{
qtTranslator1.load(":/tr/qt_" + langList.at(0) + ".qm");
}
}
}
a.installTranslator(&qtTranslator1);
#endif
// End internal translate loading
QStringList applicationArgs = a.arguments();
QString selectedAction;
QString arg1;
@ -131,3 +274,4 @@ int main(int argc, char *argv[])
return a.exec();
}

BIN
qt_de.qm Executable file

Binary file not shown.

BIN
qtbase_de.qm Executable file

Binary file not shown.