Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build: Generate qm files and embedded resource during build #3288

Merged
merged 4 commits into from
Jun 22, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .gitignore
pljones marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Jamulus
Jamulus.ini
Makefile
Makefile.*
*.pro.user*
**.cppe
**.he
Expand All @@ -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
Expand Down
30 changes: 12 additions & 18 deletions Jamulus.pro
Original file line number Diff line number Diff line change
@@ -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)
ann0see marked this conversation as resolved.
Show resolved Hide resolved
}

# 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.)
Expand All @@ -22,7 +28,8 @@ contains(VERSION, .*dev.*) {

CONFIG += qt \
thread \
lrelease
lrelease \
embed_translations

QT += network \
xml \
Expand All @@ -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 \
Expand Down Expand Up @@ -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 \
Expand Down Expand Up @@ -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 \
Expand Down
1 change: 0 additions & 1 deletion linux/debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -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)"

Expand Down
40 changes: 0 additions & 40 deletions src/resources.qrc
Original file line number Diff line number Diff line change
@@ -1,44 +1,4 @@
<RCC>
<qresource prefix="/translations">
<file alias="translation_de">translation/translation_de_DE.qm</file>
</qresource>
<qresource prefix="/translations">
<file alias="translation_fr">translation/translation_fr_FR.qm</file>
</qresource>
<qresource prefix="/translations">
<file alias="translation_pt_PT">translation/translation_pt_PT.qm</file>
</qresource>
<qresource prefix="/translations">
<file alias="translation_pt">translation/translation_pt_BR.qm</file>
</qresource>
<qresource prefix="/translations">
<file alias="translation_es">translation/translation_es_ES.qm</file>
</qresource>
<qresource prefix="/translations">
<file alias="translation_nb_NO">translation/translation_nb_NO.qm</file>
</qresource>
<qresource prefix="/translations">
<file alias="translation_nl">translation/translation_nl_NL.qm</file>
</qresource>
<qresource prefix="/translations">
<file alias="translation_it">translation/translation_it_IT.qm</file>
</qresource>
<qresource prefix="/translations">
<file alias="translation_pl">translation/translation_pl_PL.qm</file>
</qresource>
<qresource prefix="/translations">
<file alias="translation_sk">translation/translation_sk_SK.qm</file>
</qresource>
<qresource prefix="/translations">
<file alias="translation_sv">translation/translation_sv_SE.qm</file>
</qresource>
<qresource prefix="/translations">
<file alias="translation_zh_CN">translation/translation_zh_CN.qm</file>
</qresource>
<qresource prefix="/translations">
<file alias="translation_ko_KR">translation/translation_ko_KR.qm</file>
</qresource>

<qresource prefix="/png/LEDs">
<file>res/CLEDDisabled.png</file>
<file>res/CLEDGrey.png</file>
Expand Down
Binary file removed src/translation/translation_de_DE.qm
Binary file not shown.
Binary file removed src/translation/translation_es_ES.qm
Binary file not shown.
Binary file removed src/translation/translation_fr_FR.qm
Binary file not shown.
Binary file removed src/translation/translation_it_IT.qm
Binary file not shown.
Binary file removed src/translation/translation_ko_KR.qm
Binary file not shown.
Binary file removed src/translation/translation_nb_NO.qm
Binary file not shown.
Binary file removed src/translation/translation_nl_NL.qm
Binary file not shown.
Binary file removed src/translation/translation_pl_PL.qm
Binary file not shown.
Binary file removed src/translation/translation_pt_BR.qm
Binary file not shown.
Binary file removed src/translation/translation_pt_PT.qm
Binary file not shown.
Binary file removed src/translation/translation_sk_SK.qm
Binary file not shown.
Binary file removed src/translation/translation_sv_SE.qm
Binary file not shown.
Binary file removed src/translation/translation_zh_CN.qm
Binary file not shown.
11 changes: 8 additions & 3 deletions src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1602,7 +1602,11 @@ QString CLocale::GetCountryFlagIconsResourceReference ( const QLocale::Country e
QMap<QString, QString> CLocale::GetAvailableTranslations()
{
QMap<QString, QString> 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
Expand All @@ -1612,8 +1616,9 @@ QMap<QString, QString> 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"
pljones marked this conversation as resolved.
Show resolved Hide resolved
const int lang = strCurFileName.indexOf ( "_" ) + 1;
const QString strLoc = strCurFileName.mid ( lang, strCurFileName.indexOf ( "." ) - lang );

TranslMap[strLoc] = strCurFileName;
}
Expand Down
Loading