diff --git a/.gitignore b/.gitignore index 069d1f6bab..17c8a97d20 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ Jamulus Jamulus.ini Makefile +Makefile.* *.pro.user* **.cppe **.he @@ -17,7 +18,11 @@ Makefile moc_*.cpp ui_*.h moc_predefs.h -src/res/qrc_resources.cpp +.qm/ +*.qm +qmake_qmake_qm_files.qrc +qrc_qmake_qmake_qm_files.cpp +qrc_resources.cpp libs/ASIOSDK2 windows/VC_redist.x64.exe windows/vc_redist.x86.exe diff --git a/Jamulus.pro b/Jamulus.pro index 8502cde225..0ebabdbd4a 100644 --- a/Jamulus.pro +++ b/Jamulus.pro @@ -1,5 +1,11 @@ VERSION = 3.10.0dev +# Using lrelease and embed_translations only works for Qt 5.12 or later. +# See https://github.com/jamulussoftware/jamulus/pull/3288 for these changes. +lessThan(QT_MAJOR_VERSION, 5) | equals(QT_MAJOR_VERSION, 5) : lessThan(QT_MINOR_VERSION, 12) { + error(Jamulus requires at least Qt5.12. See https://github.com/jamulussoftware/jamulus/pull/3288) +} + # use target name which does not use a capital letter at the beginning contains(CONFIG, "noupcasename") { message(The target name is jamulus instead of Jamulus.) @@ -22,7 +28,8 @@ contains(VERSION, .*dev.*) { CONFIG += qt \ thread \ - lrelease + lrelease \ + embed_translations QT += network \ xml \ @@ -42,9 +49,8 @@ contains(CONFIG, "headless") { QT += multimedia } -# Hint: When adding new translations, make sure to update -# DISTFILES (above) and src/resources.qrc as well. -LRELEASE_DIR = src/translation +# Do not set LRELEASE_DIR explicitly when using embed_translations. +# It doesn't work with multiple targets or architectures. TRANSLATIONS = src/translation/translation_de_DE.ts \ src/translation/translation_fr_FR.ts \ src/translation/translation_ko_KR.ts \ @@ -357,7 +363,8 @@ win32 { } } -RCC_DIR = src/res +# Do not set RCC_DIR explicitly when using embed_translations. +# It doesn't work with multiple targets or architectures. RESOURCES += src/resources.qrc FORMS_GUI = src/aboutdlgbase.ui \ @@ -702,19 +709,6 @@ DISTFILES += ChangeLog \ src/res/io.jamulus.jamulus.png \ src/res/io.jamulus.jamulus.svg \ src/res/io.jamulus.jamulusserver.svg \ - src/translation/translation_de_DE.qm \ - src/translation/translation_fr_FR.qm \ - src/translation/translation_ko_KR.qm \ - src/translation/translation_pt_PT.qm \ - src/translation/translation_pt_BR.qm \ - src/translation/translation_es_ES.qm \ - src/translation/translation_nb_NO.qm \ - src/translation/translation_nl_NL.qm \ - src/translation/translation_pl_PL.qm \ - src/translation/translation_it_IT.qm \ - src/translation/translation_sv_SE.qm \ - src/translation/translation_sk_SK.qm \ - src/translation/translation_zh_CN.qm \ src/res/CLEDBlack.png \ src/res/CLEDBlackSmall.png \ src/res/CLEDDisabledSmall.png \ diff --git a/linux/debian/rules b/linux/debian/rules index bb1f655499..307e7db0ca 100755 --- a/linux/debian/rules +++ b/linux/debian/rules @@ -35,7 +35,6 @@ override_dh_auto_configure: mkdir -p build-nox && cd build-nox && $(QMAKE) "CONFIG+=headless serveronly" TARGET=jamulus-headless PREFIX=/usr ../Jamulus.pro override_dh_auto_build: - cd src/translation && lrelease *.ts cd build-gui && make -j "$$(nproc)" cd build-nox && make -j "$$(nproc)" diff --git a/src/resources.qrc b/src/resources.qrc index 279ddde6fe..502a459b64 100644 --- a/src/resources.qrc +++ b/src/resources.qrc @@ -1,44 +1,4 @@ - - translation/translation_de_DE.qm - - - translation/translation_fr_FR.qm - - - translation/translation_pt_PT.qm - - - translation/translation_pt_BR.qm - - - translation/translation_es_ES.qm - - - translation/translation_nb_NO.qm - - - translation/translation_nl_NL.qm - - - translation/translation_it_IT.qm - - - translation/translation_pl_PL.qm - - - translation/translation_sk_SK.qm - - - translation/translation_sv_SE.qm - - - translation/translation_zh_CN.qm - - - translation/translation_ko_KR.qm - - res/CLEDDisabled.png res/CLEDGrey.png diff --git a/src/translation/translation_de_DE.qm b/src/translation/translation_de_DE.qm deleted file mode 100644 index 7afba014e1..0000000000 Binary files a/src/translation/translation_de_DE.qm and /dev/null differ diff --git a/src/translation/translation_es_ES.qm b/src/translation/translation_es_ES.qm deleted file mode 100644 index fc5ef9263d..0000000000 Binary files a/src/translation/translation_es_ES.qm and /dev/null differ diff --git a/src/translation/translation_fr_FR.qm b/src/translation/translation_fr_FR.qm deleted file mode 100644 index e9b8b656a8..0000000000 Binary files a/src/translation/translation_fr_FR.qm and /dev/null differ diff --git a/src/translation/translation_it_IT.qm b/src/translation/translation_it_IT.qm deleted file mode 100644 index b939aaa300..0000000000 Binary files a/src/translation/translation_it_IT.qm and /dev/null differ diff --git a/src/translation/translation_ko_KR.qm b/src/translation/translation_ko_KR.qm deleted file mode 100644 index 2f5cef8443..0000000000 Binary files a/src/translation/translation_ko_KR.qm and /dev/null differ diff --git a/src/translation/translation_nb_NO.qm b/src/translation/translation_nb_NO.qm deleted file mode 100644 index 04ffe6c221..0000000000 Binary files a/src/translation/translation_nb_NO.qm and /dev/null differ diff --git a/src/translation/translation_nl_NL.qm b/src/translation/translation_nl_NL.qm deleted file mode 100644 index 77dbaf5d10..0000000000 Binary files a/src/translation/translation_nl_NL.qm and /dev/null differ diff --git a/src/translation/translation_pl_PL.qm b/src/translation/translation_pl_PL.qm deleted file mode 100644 index 8d2a7c3ee2..0000000000 Binary files a/src/translation/translation_pl_PL.qm and /dev/null differ diff --git a/src/translation/translation_pt_BR.qm b/src/translation/translation_pt_BR.qm deleted file mode 100644 index adc04e1eb5..0000000000 Binary files a/src/translation/translation_pt_BR.qm and /dev/null differ diff --git a/src/translation/translation_pt_PT.qm b/src/translation/translation_pt_PT.qm deleted file mode 100644 index d1f566001b..0000000000 Binary files a/src/translation/translation_pt_PT.qm and /dev/null differ diff --git a/src/translation/translation_sk_SK.qm b/src/translation/translation_sk_SK.qm deleted file mode 100644 index ada6c37ef2..0000000000 Binary files a/src/translation/translation_sk_SK.qm and /dev/null differ diff --git a/src/translation/translation_sv_SE.qm b/src/translation/translation_sv_SE.qm deleted file mode 100644 index d2c2dce13d..0000000000 Binary files a/src/translation/translation_sv_SE.qm and /dev/null differ diff --git a/src/translation/translation_zh_CN.qm b/src/translation/translation_zh_CN.qm deleted file mode 100644 index 0f4225b95e..0000000000 Binary files a/src/translation/translation_zh_CN.qm and /dev/null differ diff --git a/src/util.cpp b/src/util.cpp index 0111586a81..cdbcee448e 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -1602,7 +1602,11 @@ QString CLocale::GetCountryFlagIconsResourceReference ( const QLocale::Country e QMap CLocale::GetAvailableTranslations() { QMap TranslMap; - QDirIterator DirIter ( ":/translations" ); + + // Since we use "embed_translations" in Jamulus.pro, this resource prefix must + // match the default prefix used by qmake when generating the resource file. + // That prefix is "i18n" (standard abbreviation for internationalisation). + QDirIterator DirIter ( ":/i18n" ); // add english language (default which is in the actual source code) TranslMap["en"] = ""; // empty file name means that the translation load fails and we get the default english language @@ -1612,8 +1616,9 @@ QMap CLocale::GetAvailableTranslations() // get alias of translation file const QString strCurFileName = DirIter.next(); - // extract only language code (must be at the end, separated with a "_") - const QString strLoc = strCurFileName.right ( strCurFileName.length() - strCurFileName.indexOf ( "_" ) - 1 ); + // extract only language code "xx_XX" from "translation_xx_XX.qm" + const int lang = strCurFileName.indexOf ( "_" ) + 1; + const QString strLoc = strCurFileName.mid ( lang, strCurFileName.indexOf ( "." ) - lang ); TranslMap[strLoc] = strCurFileName; }