diff --git a/QuasarApp.pro b/QuasarApp.pro index 9157cbc..085d89a 100644 --- a/QuasarApp.pro +++ b/QuasarApp.pro @@ -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 diff --git a/locales.cpp b/locales.cpp index 039114e..2463bff 100644 --- a/locales.cpp +++ b/locales.cpp @@ -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; } diff --git a/locales.h b/locales.h index 7245fb9..60c8ce8 100644 --- a/locales.h +++ b/locales.h @@ -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); }; } diff --git a/qmakeEtalons/locales.pri b/qmakeEtalons/locales.pri new file mode 100755 index 0000000..29beadc --- /dev/null +++ b/qmakeEtalons/locales.pri @@ -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") +} +