Browse Source

QMake: Compile translations at build time

adaptive-webui-19844
Vladimir Golovnev (Glassez) 6 years ago
parent
commit
7b3eed323b
No known key found for this signature in database
GPG Key ID: 52A2C7DEE2DFA6F7
  1. 4
      qbittorrent.pro
  2. 2
      src/app/main.cpp
  3. 28
      src/lang/lang.pri
  4. 21
      src/src.pro
  5. 24
      src/webui/webui.pri

4
qbittorrent.pro

@ -17,10 +17,6 @@ tarball.commands += rm -fR $${PROJECT_NAME}-$${PROJECT_VERSION}
QMAKE_EXTRA_TARGETS += tarball 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 # For Qt Creator beautifier
DISTFILES += \ DISTFILES += \
uncrustify.cfg uncrustify.cfg

2
src/app/main.cpp

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

28
src/lang/lang.pri

@ -1,28 +0,0 @@
TS_FILES += $$files(qbittorrent_*.ts)
# need to use full path, otherwise running
# `lupdate` will generate *.ts files in project root directory
for(file, TS_FILES) {
TRANSLATIONS += "$${PWD}/$${file}"
}
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
}
}
message("Building translations")
TS_FILES_NOEXT = $$replace(TS_FILES, ".ts", "")
for(file, TS_FILES_NOEXT) {
message("Processing $${file}")
system("$$QMAKE_LRELEASE -silent $${file}.ts -qm $${file}.qm")
!exists("$${file}.qm"):error("Building translations failed, cannot continue")
}

21
src/src.pro

@ -66,6 +66,27 @@ include(base/base.pri)
!nogui: include(gui/gui.pri) !nogui: include(gui/gui.pri)
!nowebui: include(webui/webui.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 # Resource files
QMAKE_RESOURCE_FLAGS += -compress 9 -threshold 5 QMAKE_RESOURCE_FLAGS += -compress 9 -threshold 5
RESOURCES += \ RESOURCES += \

24
src/webui/webui.pri

@ -31,26 +31,6 @@ SOURCES += \
$$PWD/webapplication.cpp \ $$PWD/webapplication.cpp \
$$PWD/webui.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 RESOURCES += $$PWD/www/webui.qrc $$PWD/www/translations/webui_translations.qrc
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!")
}

Loading…
Cancel
Save