From b606a128c91be8ccdaae09b4efb87f9b453b508c Mon Sep 17 00:00:00 2001 From: Tony Mountifield Date: Mon, 14 Feb 2022 16:36:00 +0000 Subject: [PATCH 1/7] Testing embed_translations --- Jamulus.pro | 2 +- src/resources.qrc | 40 ---------------------------------------- 2 files changed, 1 insertion(+), 41 deletions(-) diff --git a/Jamulus.pro b/Jamulus.pro index 0b2fb55cb5..8886146452 100644 --- a/Jamulus.pro +++ b/Jamulus.pro @@ -22,7 +22,7 @@ contains(VERSION, .*dev.*) { CONFIG += qt \ thread \ - lrelease + lrelease embed_translations QT += network \ xml \ 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 From 2d4aa4230210cc3732cedf184d183b244cdd9845 Mon Sep 17 00:00:00 2001 From: Tony Mountifield Date: Mon, 14 Feb 2022 16:53:25 +0000 Subject: [PATCH 2/7] Add generated files to .gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 069d1f6bab..fadeba16a3 100644 --- a/.gitignore +++ b/.gitignore @@ -47,3 +47,6 @@ Jamulus.xcodeproj jamulus_plugin_import.cpp .github_release_changelog.md /debian/ +src/res/qmake_qmake_qm_files.qrc +src/res/qrc_qmake_qmake_qm_files.cpp +src/res/translation/*.qm From 91ac701361977154598d2a4c5060f0b462e836d8 Mon Sep 17 00:00:00 2001 From: Tony Mountifield Date: Mon, 14 Feb 2022 17:24:53 +0000 Subject: [PATCH 3/7] Change resource path for translations to match qmake --- src/util.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util.cpp b/src/util.cpp index 421706c43f..214000d088 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -1583,7 +1583,7 @@ QString CLocale::GetCountryFlagIconsResourceReference ( const QLocale::Country e QMap CLocale::GetAvailableTranslations() { QMap TranslMap; - QDirIterator DirIter ( ":/translations" ); + 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 From 5dede3a09d134911f913cc7bde0bbaf7927b0942 Mon Sep 17 00:00:00 2001 From: Tony Mountifield Date: Mon, 14 Feb 2022 18:21:05 +0000 Subject: [PATCH 4/7] Update extraction of language identifier from filename --- src/util.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/util.cpp b/src/util.cpp index 214000d088..21032aa77a 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -1593,8 +1593,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; } From 12c6068c47b7531180323a625350f6769a7f15ac Mon Sep 17 00:00:00 2001 From: Tony Mountifield Date: Wed, 23 Mar 2022 16:43:33 +0000 Subject: [PATCH 5/7] Remove .qm files from file list --- Jamulus.pro | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/Jamulus.pro b/Jamulus.pro index 8886146452..dde8309e2d 100644 --- a/Jamulus.pro +++ b/Jamulus.pro @@ -707,19 +707,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 \ From f4e57b3672e844f8de019feef4c818f67189cd5f Mon Sep 17 00:00:00 2001 From: Tony Mountifield Date: Wed, 23 Mar 2022 16:44:08 +0000 Subject: [PATCH 6/7] First attempt at lrelease rules for Qt < 5.12 --- Jamulus.pro | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/Jamulus.pro b/Jamulus.pro index dde8309e2d..275e1043b0 100644 --- a/Jamulus.pro +++ b/Jamulus.pro @@ -1,5 +1,9 @@ VERSION = 3.9.1dev +lessThan(QT_MAJOR_VERSION, 5) { + error(Jamulus requires at least Qt5) +} + # 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.) @@ -1164,3 +1168,42 @@ CLANG_FORMAT_SOURCES = $$find(CLANG_FORMAT_SOURCES, ^\(android|ios|mac|linux|src CLANG_FORMAT_SOURCES ~= s!^\(libs/.*/|src/res/qrc_resources\.cpp\)\S*$!!g clang_format.commands = 'clang-format -i $$CLANG_FORMAT_SOURCES' QMAKE_EXTRA_TARGETS += clang_format + +equals(QT_MAJOR_VERSION, 5) { + lessThan(QT_MINOR_VERSION, 12) { + message(Using extra lrelease rules for old Qt5) + + qtPrepareTool(QMAKE_LRELEASE, lrelease) + + isEmpty(LRELEASE_DIR): LRELEASE_DIR = .qm + isEmpty(QM_FILES_RESOURCE_PREFIX): QM_FILES_RESOURCE_PREFIX = i18n + + lrelease.name = lrelease + lrelease.input = TRANSLATIONS EXTRA_TRANSLATIONS + lrelease.output = $$LRELEASE_DIR/${QMAKE_FILE_IN_BASE}.qm + lrelease.commands = $$QMAKE_LRELEASE ${QMAKE_FILE_IN} $$QMAKE_LRELEASE_FLAGS -qm ${QMAKE_FILE_OUT} + silent: lrelease.commands = @echo lrelease ${QMAKE_FILE_IN} && $$lrelease.commands + lrelease.CONFIG = no_link + QMAKE_EXTRA_COMPILERS += lrelease + + all_translations = $$TRANSLATIONS $$EXTRA_TRANSLATIONS + for (translation, all_translations) { + # mirrors $$LRELEASE_DIR/${QMAKE_FILE_IN_BASE}.qm above + translation = $$basename(translation) + QM_FILES += $$OUT_PWD/$$LRELEASE_DIR/$$replace(translation, \\..*$, .qm) + } + embed_translations { + qmake_qm_files.files = $$QM_FILES + qmake_qm_files.base = $$OUT_PWD/$$LRELEASE_DIR + qmake_qm_files.prefix = $$QM_FILES_RESOURCE_PREFIX + RESOURCES += qmake_qm_files + } else { + !isEmpty(QM_FILES_INSTALL_PATH) { + qm_files.files = $$QM_FILES + qm_files.path = $$QM_FILES_INSTALL_PATH + INSTALLS += qm_files + } + lrelease.CONFIG += target_predeps no_clean + } + } +} From cd78c0bb482798e1d8f3a430ad0e80489e3bdd6c Mon Sep 17 00:00:00 2001 From: Tony Mountifield Date: Wed, 23 Mar 2022 22:57:16 +0000 Subject: [PATCH 7/7] Working lrelease rules for Qt < 5.12 --- Jamulus.pro | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Jamulus.pro b/Jamulus.pro index 275e1043b0..75d514e2de 100644 --- a/Jamulus.pro +++ b/Jamulus.pro @@ -1171,7 +1171,7 @@ QMAKE_EXTRA_TARGETS += clang_format equals(QT_MAJOR_VERSION, 5) { lessThan(QT_MINOR_VERSION, 12) { - message(Using extra lrelease rules for old Qt5) + message(Using extra lrelease rules for old Qt5 *** IGNORE the RCC errors below ***) qtPrepareTool(QMAKE_LRELEASE, lrelease) @@ -1197,6 +1197,11 @@ equals(QT_MAJOR_VERSION, 5) { qmake_qm_files.base = $$OUT_PWD/$$LRELEASE_DIR qmake_qm_files.prefix = $$QM_FILES_RESOURCE_PREFIX RESOURCES += qmake_qm_files + + # This is a hack because old rcc does not output dependencies that do not yet exist. + # This adds the QM files as explicit dependencies of all resource files, but that + # does not matter - it still ensures the qm files get built on the fly. + rcc.depends += $$QM_FILES } else { !isEmpty(QM_FILES_INSTALL_PATH) { qm_files.files = $$QM_FILES