version 1.1

This commit is contained in:
Andrei Yankovich 2018-12-06 21:30:48 +03:00
parent fcf00ff458
commit 89b880fdd0
4 changed files with 46 additions and 8 deletions

View File

@ -1,8 +1,10 @@
#-------------------------------------------------
#
# Project created by QtCreator 2018-07-24T20:32:41
# Copyright (C) 2018 QuasarApp.
# Distributed under the lgplv3 software license, see the accompanying
# Everyone is permitted to copy and distribute verbatim copies
# of this license document, but changing it is not allowed.
#
#-------------------------------------------------
QT -= gui
@ -43,7 +45,8 @@ HEADERS += \
settings.h
DISTFILES += \
QuasarLib.pri
QuasarLib.pri \
qmakeEtalons/locales.pri
RESOURCES += \
res.qrc

View File

@ -14,16 +14,17 @@
using namespace QuasarAppUtils;
bool Locales::initLocale(const QString &locale, QCoreApplication *app, QTranslator *translator){
bool Locales::initLocale(const QString& prefix, const QString &locale, QCoreApplication *app, QTranslator *translator){
QString defaultLocale = QLocale::system().name();
defaultLocale.truncate(defaultLocale.lastIndexOf('_'));
if(!locale.isEmpty() && translator->load(QString(":/languages/%0").arg(locale))){
if(!locale.isEmpty() && translator->load(QString("%0/%1").arg(prefix, locale))) {
return app->installTranslator(translator);
}
if(!translator->load(QString(":/languages/%0").arg(defaultLocale))){
if(!translator->load(QString("%0/%1").arg(prefix, defaultLocale))) {
return false;
}

View File

@ -26,12 +26,13 @@ public:
/**
* @brief initLocale init translation of applictaion
* @param prefix - path to folder with qm files. example (/home)
* @param locale - string value of locale. example (en)
* @param app - app core of qt
* @param translator - translator core of qt
* @return return true if locale funded
*/
static bool initLocale(const QString &locale, QCoreApplication* app, QTranslator *translator);
static bool initLocale(const QString& prefix ,const QString &locale, QCoreApplication* app, QTranslator *translator);
};
}

33
qmakeEtalons/locales.pri Executable file
View File

@ -0,0 +1,33 @@
#
# Copyright (C) 2018 QuasarApp.
# Distributed under the lgplv3 software license, see the accompanying
# Everyone is permitted to copy and distribute verbatim copies
# of this license document, but changing it is not allowed.
#
QT_DIR = $$dirname(QMAKE_QMAKE)
LUPDATE = $$QT_DIR/lupdate
LRELEASE = $$QT_DIR/lrelease
win32 {
LUPDATE = $${LUPDATE}.exe
LRELEASE = $${LRELEASE}.exe
}
PRO_FILES = $$files(*.pro, true)
for(PRO, PRO_FILES) {
commands += "$$LUPDATE $$PRO"
}
TS_FILES = $$files(*.ts, true)
for(TS, TS_FILES) {
commands += "$$LRELEASE $$TS"
}
for(command, commands) {
system($$command)|error("Failed to run: $$command")
}