From 6191bed3ee649053e6f41c2c4ae7e88e21f09ba0 Mon Sep 17 00:00:00 2001 From: xiaoyifang Date: Sun, 27 Mar 2022 21:03:57 +0800 Subject: [PATCH] optimize: embed ts files in linux appimage ,translation files can not be read in the AppImage. --- config.cc | 9 +++++---- goldendict.pro | 54 ++++++++------------------------------------------ 2 files changed, 13 insertions(+), 50 deletions(-) diff --git a/config.cc b/config.cc index 3dfed614..1139a2c3 100644 --- a/config.cc +++ b/config.cc @@ -2287,10 +2287,11 @@ QString getProgramDataDir() throw() QString getLocDir() throw() { - if ( QDir( getProgramDataDir() ).cd( "locale" ) ) - return getProgramDataDir() + "/locale"; - else - return QCoreApplication::applicationDirPath() + "/locale"; + return ":/locale"; +// if ( QDir( getProgramDataDir() ).cd( "locale" ) ) +// return getProgramDataDir() + "/locale"; +// else +// return QCoreApplication::applicationDirPath() + "/locale"; } QString getHelpDir() throw() diff --git a/goldendict.pro b/goldendict.pro index 9c3c64bf..314650de 100644 --- a/goldendict.pro +++ b/goldendict.pro @@ -46,18 +46,19 @@ QT += sql CONFIG += exceptions \ rtti \ stl \ - c++11 - # lrelease #lrelease generate qm under target folder. + c++11 \ + lrelease \ + embed_translations mac { - CONFIG += app_bundle + DEBUG:CONFIG += app_bundle } - -QM_FILES_INSTALL_PATH = /locale/ + +QM_FILES_RESOURCE_PREFIX = /locale/ OBJECTS_DIR = build UI_DIR = build MOC_DIR = build -RCC_DIR = build +#RCC_DIR = build LIBS += \ -lz \ -lbz2 \ @@ -550,6 +551,7 @@ CONFIG( chinese_conversion_support ) { RESOURCES += resources.qrc \ flags.qrc +#EXTRA_TRANSLATIONS += thirdparty/qwebengine_ts/qtwebengine_zh_CN.ts TRANSLATIONS += locale/ru_RU.ts \ locale/zh_CN.ts \ locale/cs_CZ.ts \ @@ -592,50 +594,10 @@ TRANSLATIONS += locale/ru_RU.ts \ # Build version file !isEmpty( hasGit ) { - QMAKE_EXTRA_TARGETS += revtarget PRE_TARGETDEPS += $$PWD/version.txt - revtarget.target = $$PWD/version.txt - -# !win32 { -# revtarget.commands = cd $$PWD; git describe --tags --always --dirty > $$revtarget.target -# } else { -# revtarget.commands = git --git-dir=\"$$PWD/.git\" describe --tags --always --dirty > $$revtarget.target -# } - - ALL_SOURCES = $$SOURCES $$HEADERS $$FORMS - for(src, ALL_SOURCES) { - QUALIFIED_SOURCES += $${PWD}/$${src} - } - revtarget.depends = $$QUALIFIED_SOURCES } -# 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 )