diff --git a/config.cc b/config.cc index a86e8c7c..b4c4a186 100644 --- a/config.cc +++ b/config.cc @@ -2264,17 +2264,12 @@ QString getProgramDataDir() noexcept #endif } -QString getEmbedLocDir() noexcept -{ - return ":/locale"; -} - QString getLocDir() noexcept { - if ( QDir( getProgramDataDir() ).cd( "locale" ) ) - return getProgramDataDir() + "/locale"; - else - return QCoreApplication::applicationDirPath() + "/locale"; + if ( QDir( getProgramDataDir() ).cd( "locale" ) ) + return getProgramDataDir() + "/locale"; + else + return QCoreApplication::applicationDirPath() + "/locale"; } QString getHelpDir() noexcept diff --git a/config.hh b/config.hh index 06d21ccf..012382cf 100644 --- a/config.hh +++ b/config.hh @@ -811,7 +811,6 @@ QString getUserQtCssFileName() ; QString getProgramDataDir() noexcept; /// Returns the directory storing program localizized files (.qm). -QString getEmbedLocDir() noexcept; QString getLocDir() noexcept; /// Returns the directory storing program help files (.qch). diff --git a/goldendict.pro b/goldendict.pro index fcd3e68a..b23f6a35 100644 --- a/goldendict.pro +++ b/goldendict.pro @@ -69,19 +69,18 @@ CONFIG += exceptions \ stl \ c++17 \ lrelease \ - embed_translations \ utf8_source \ force_debug_info mac { - DEBUG:CONFIG += app_bundle + CONFIG += app_bundle } - -QM_FILES_RESOURCE_PREFIX = /locale/ + +QM_FILES_INSTALL_PATH = /locale/ OBJECTS_DIR = build UI_DIR = build MOC_DIR = build -#RCC_DIR = build +RCC_DIR = build LIBS += -lz \ -lbz2 \ -llzo2 @@ -628,13 +627,38 @@ TRANSLATIONS += locale/ru_RU.ts \ locale/jb_JB.ts \ locale/hi_IN.ts \ locale/ie_001.ts - # Build version file !isEmpty( hasGit ) { PRE_TARGETDEPS += $$PWD/version.txt } +# This makes qmake generate translations +isEmpty(QMAKE_LRELEASE):QMAKE_LRELEASE = $$[QT_INSTALL_BINS]/lrelease + + +# The *.qm files might not exist when qmake is run for the first time, +# causing the standard install rule to be ignored, and no translations +# will be installed. With this, we create the qm files during qmake run. +!win32 { + system($${QMAKE_LRELEASE} -silent $${_PRO_FILE_} 2> /dev/null) +} +else{ + system($${QMAKE_LRELEASE} -silent $${_PRO_FILE_}) +} + +updateqm.input = TRANSLATIONS +updateqm.output = locale/${QMAKE_FILE_BASE}.qm +updateqm.commands = $$QMAKE_LRELEASE \ + ${QMAKE_FILE_IN} \ + -qm \ + ${QMAKE_FILE_OUT} +updateqm.CONFIG += no_link +QMAKE_EXTRA_COMPILERS += updateqm +TS_OUT = $$TRANSLATIONS +TS_OUT ~= s/.ts/.qm/g +PRE_TARGETDEPS += $$TS_OUT + include( thirdparty/qtsingleapplication/src/qtsingleapplication.pri ) diff --git a/main.cc b/main.cc index 65a05758..28afaba6 100644 --- a/main.cc +++ b/main.cc @@ -399,7 +399,7 @@ int main( int argc, char ** argv ) app.installTranslator( &qtTranslator ); } - translator.load( Config::getEmbedLocDir() + "/" + localeName ); + translator.load( Config::getLocDir() + "/" + localeName ); app.installTranslator( &translator ); QTranslator webengineTs; diff --git a/preferences.cc b/preferences.cc index 7068341a..535f5039 100644 --- a/preferences.cc +++ b/preferences.cc @@ -41,7 +41,7 @@ Preferences::Preferences( QWidget * parent, Config::Class & cfg_ ): // See which other translations do we have - QStringList availLocs = QDir( Config::getEmbedLocDir() ).entryList( QStringList( "*.qm" ), + QStringList availLocs = QDir( Config::getLocDir() ).entryList( QStringList( "*.qm" ), QDir::Files ); // We need to sort by language name -- otherwise list looks really weird