mirror of
https://github.com/QuasarApp/QuasarAppLib.git
synced 2025-05-05 22:19:43 +00:00
commit
9fea7e8530
@ -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
|
||||
|
||||
@ -42,13 +44,9 @@ HEADERS += \
|
||||
locales.h \
|
||||
settings.h
|
||||
|
||||
unix {
|
||||
target.path = /usr/lib
|
||||
INSTALLS += target
|
||||
}
|
||||
|
||||
DISTFILES += \
|
||||
QuasarLib.pri
|
||||
QuasarLib.pri \
|
||||
qmakeEtalons/locales.pri
|
||||
|
||||
RESOURCES += \
|
||||
res.qrc
|
||||
|
@ -10,12 +10,12 @@ QUASARAPP_LIB = 1
|
||||
|
||||
#DEPENDS
|
||||
CONFIG(release, debug|release): {
|
||||
LIBS += -L"$$PWD/build/release" -lQuasarApp
|
||||
|
||||
QUASARAPP_LIB_OUTPUT_DIR="$$PWD/build/release"
|
||||
} else {
|
||||
LIBS += -L"$$PWD/build/debug" -lQuasarApp
|
||||
QUASARAPP_LIB_OUTPUT_DIR="$$PWD/build/debug"
|
||||
}
|
||||
|
||||
LIBS += -L$$QUASARAPP_LIB_OUTPUT_DIR -lQuasarApp
|
||||
|
||||
INCLUDEPATH += "$$PWD/"
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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
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