Permalink
Browse files

QMake: Compile translations at build time

  • Loading branch information...
glassez committed Dec 20, 2018
1 parent 8ab94d7 commit 7b3eed323b92a21c14482793b6770d25518cddc9
Showing with 24 additions and 55 deletions.
  1. +0 −4 qbittorrent.pro
  2. +1 −1 src/app/main.cpp
  3. +0 −28 src/lang/lang.pri
  4. +21 −0 src/src.pro
  5. +2 −22 src/webui/webui.pri
@@ -17,10 +17,6 @@ tarball.commands += rm -fR $${PROJECT_NAME}-$${PROJECT_VERSION}

QMAKE_EXTRA_TARGETS += tarball

# Translations included here (at top level) is to avoid regenerating the .qm files
# every time when src.pro is processed
include(src/lang/lang.pri)

# For Qt Creator beautifier
DISTFILES += \
uncrustify.cfg
@@ -78,7 +78,7 @@ void sigNormalHandler(int signum);
void sigAbnormalHandler(int signum);
#endif
// sys_signame[] is only defined in BSD
const char *sysSigName[] = {
const char *const sysSigName[] = {
#if defined(Q_OS_WIN)
"", "", "SIGINT", "", "SIGILL", "", "SIGABRT_COMPAT", "", "SIGFPE", "",
"", "SIGSEGV", "", "", "", "SIGTERM", "", "", "", "",

This file was deleted.

Oops, something went wrong.
@@ -66,6 +66,27 @@ include(base/base.pri)
!nogui: include(gui/gui.pri)
!nowebui: include(webui/webui.pri)

isEmpty(QMAKE_LRELEASE) {
win32: QMAKE_LRELEASE = $$[QT_INSTALL_BINS]/lrelease.exe
else: QMAKE_LRELEASE = $$[QT_INSTALL_BINS]/lrelease
unix {
equals(QT_MAJOR_VERSION, 5) {
!exists($$QMAKE_LRELEASE): QMAKE_LRELEASE = lrelease-qt5
}
}
else {
!exists($$QMAKE_LRELEASE): QMAKE_LRELEASE = lrelease
}
}
lrelease.input = TS_SOURCES
lrelease.output = ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}.qm
lrelease.commands = @echo "lrelease ${QMAKE_FILE_NAME}" && $$QMAKE_LRELEASE -silent ${QMAKE_FILE_NAME} -qm ${QMAKE_FILE_OUT}
lrelease.CONFIG += no_link target_predeps
QMAKE_EXTRA_COMPILERS += lrelease

TRANSLATIONS = $$files($$PWD/lang/qbittorrent_*.ts)
TS_SOURCES += $$TRANSLATIONS

# Resource files
QMAKE_RESOURCE_FLAGS += -compress 9 -threshold 5
RESOURCES += \
@@ -31,26 +31,6 @@ SOURCES += \
$$PWD/webapplication.cpp \
$$PWD/webui.cpp

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

# WebUI Translation
isEmpty(QMAKE_LRELEASE) {
win32: QMAKE_LRELEASE = $$[QT_INSTALL_BINS]/lrelease.exe
else: QMAKE_LRELEASE = $$[QT_INSTALL_BINS]/lrelease
unix {
equals(QT_MAJOR_VERSION, 5) {
!exists($$QMAKE_LRELEASE): QMAKE_LRELEASE = lrelease-qt5
}
}
else {
!exists($$QMAKE_LRELEASE): QMAKE_LRELEASE = lrelease
}
}
WEBUI_TRANSLATIONS = $$files(www/translations/webui_*.ts)
WEBUI_TRANSLATIONS_NOEXT = $$replace(WEBUI_TRANSLATIONS, ".ts", "")
message("Building WebUI translations...")
for(L, WEBUI_TRANSLATIONS_NOEXT) {
message("Processing $${L}")
system("$$QMAKE_LRELEASE -silent $${L}.ts -qm $${L}.qm")
!exists("$${L}.qm"): error("Building WebUI translations failed, cannot continue!")
}
RESOURCES += $$PWD/www/webui.qrc $$PWD/www/translations/webui_translations.qrc

0 comments on commit 7b3eed3

Please sign in to comment.