Skip to content

Commit 7b3eed3

Browse files
committed
QMake: Compile translations at build time
1 parent 8ab94d7 commit 7b3eed3

5 files changed

Lines changed: 24 additions & 55 deletions

File tree

qbittorrent.pro

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ tarball.commands += rm -fR $${PROJECT_NAME}-$${PROJECT_VERSION}
1717

1818
QMAKE_EXTRA_TARGETS += tarball
1919

20-
# Translations included here (at top level) is to avoid regenerating the .qm files
21-
# every time when src.pro is processed
22-
include(src/lang/lang.pri)
23-
2420
# For Qt Creator beautifier
2521
DISTFILES += \
2622
uncrustify.cfg

src/app/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ void sigNormalHandler(int signum);
7878
void sigAbnormalHandler(int signum);
7979
#endif
8080
// sys_signame[] is only defined in BSD
81-
const char *sysSigName[] = {
81+
const char *const sysSigName[] = {
8282
#if defined(Q_OS_WIN)
8383
"", "", "SIGINT", "", "SIGILL", "", "SIGABRT_COMPAT", "", "SIGFPE", "",
8484
"", "SIGSEGV", "", "", "", "SIGTERM", "", "", "", "",

src/lang/lang.pri

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/src.pro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,27 @@ include(base/base.pri)
6666
!nogui: include(gui/gui.pri)
6767
!nowebui: include(webui/webui.pri)
6868

69+
isEmpty(QMAKE_LRELEASE) {
70+
win32: QMAKE_LRELEASE = $$[QT_INSTALL_BINS]/lrelease.exe
71+
else: QMAKE_LRELEASE = $$[QT_INSTALL_BINS]/lrelease
72+
unix {
73+
equals(QT_MAJOR_VERSION, 5) {
74+
!exists($$QMAKE_LRELEASE): QMAKE_LRELEASE = lrelease-qt5
75+
}
76+
}
77+
else {
78+
!exists($$QMAKE_LRELEASE): QMAKE_LRELEASE = lrelease
79+
}
80+
}
81+
lrelease.input = TS_SOURCES
82+
lrelease.output = ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}.qm
83+
lrelease.commands = @echo "lrelease ${QMAKE_FILE_NAME}" && $$QMAKE_LRELEASE -silent ${QMAKE_FILE_NAME} -qm ${QMAKE_FILE_OUT}
84+
lrelease.CONFIG += no_link target_predeps
85+
QMAKE_EXTRA_COMPILERS += lrelease
86+
87+
TRANSLATIONS = $$files($$PWD/lang/qbittorrent_*.ts)
88+
TS_SOURCES += $$TRANSLATIONS
89+
6990
# Resource files
7091
QMAKE_RESOURCE_FLAGS += -compress 9 -threshold 5
7192
RESOURCES += \

src/webui/webui.pri

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,26 +31,6 @@ SOURCES += \
3131
$$PWD/webapplication.cpp \
3232
$$PWD/webui.cpp
3333

34-
RESOURCES += $$PWD/www/webui.qrc $$PWD/www/translations/webui_translations.qrc
34+
TS_SOURCES += $$files($$PWD/www/translations/webui_*.ts)
3535

36-
# WebUI Translation
37-
isEmpty(QMAKE_LRELEASE) {
38-
win32: QMAKE_LRELEASE = $$[QT_INSTALL_BINS]/lrelease.exe
39-
else: QMAKE_LRELEASE = $$[QT_INSTALL_BINS]/lrelease
40-
unix {
41-
equals(QT_MAJOR_VERSION, 5) {
42-
!exists($$QMAKE_LRELEASE): QMAKE_LRELEASE = lrelease-qt5
43-
}
44-
}
45-
else {
46-
!exists($$QMAKE_LRELEASE): QMAKE_LRELEASE = lrelease
47-
}
48-
}
49-
WEBUI_TRANSLATIONS = $$files(www/translations/webui_*.ts)
50-
WEBUI_TRANSLATIONS_NOEXT = $$replace(WEBUI_TRANSLATIONS, ".ts", "")
51-
message("Building WebUI translations...")
52-
for(L, WEBUI_TRANSLATIONS_NOEXT) {
53-
message("Processing $${L}")
54-
system("$$QMAKE_LRELEASE -silent $${L}.ts -qm $${L}.qm")
55-
!exists("$${L}.qm"): error("Building WebUI translations failed, cannot continue!")
56-
}
36+
RESOURCES += $$PWD/www/webui.qrc $$PWD/www/translations/webui_translations.qrc

0 commit comments

Comments
 (0)