mirror of
https://github.com/QuasarApp/QuasarAppLib.git
synced 2025-04-28 10:44:41 +00:00
version 1.1
This commit is contained in:
parent
fcf00ff458
commit
89b880fdd0
@ -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
|
QT -= gui
|
||||||
|
|
||||||
@ -43,7 +45,8 @@ HEADERS += \
|
|||||||
settings.h
|
settings.h
|
||||||
|
|
||||||
DISTFILES += \
|
DISTFILES += \
|
||||||
QuasarLib.pri
|
QuasarLib.pri \
|
||||||
|
qmakeEtalons/locales.pri
|
||||||
|
|
||||||
RESOURCES += \
|
RESOURCES += \
|
||||||
res.qrc
|
res.qrc
|
||||||
|
@ -14,16 +14,17 @@
|
|||||||
|
|
||||||
using namespace QuasarAppUtils;
|
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();
|
QString defaultLocale = QLocale::system().name();
|
||||||
defaultLocale.truncate(defaultLocale.lastIndexOf('_'));
|
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);
|
return app->installTranslator(translator);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!translator->load(QString(":/languages/%0").arg(defaultLocale))){
|
if(!translator->load(QString("%0/%1").arg(prefix, defaultLocale))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,12 +26,13 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief initLocale init translation of applictaion
|
* @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 locale - string value of locale. example (en)
|
||||||
* @param app - app core of qt
|
* @param app - app core of qt
|
||||||
* @param translator - translator core of qt
|
* @param translator - translator core of qt
|
||||||
* @return return true if locale funded
|
* @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
33
qmakeEtalons/locales.pri
Executable 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")
|
||||||
|
}
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user