mirror of https://github.com/linuxdeepin/dtkcore
feat: support dtk_translations
Change-Id: Ibf3bb150c7861cee42fbb93ff8a95aa35cd3dce5
This commit is contained in:
parent
5023950e68
commit
a0e4443ee7
Notes:
gerrit
2018-04-12 12:56:32 +00:00
Verified+1: Anonymous Coward #1000004 Code-Review+2: Iceyer <me@iceyer.net> Submitted-by: Iceyer <me@iceyer.net> Submitted-at: Thu, 12 Apr 2018 12:56:32 +0000 Reviewed-on: https://cr.deepin.io/33606 Project: dtkcore Branch: refs/heads/master
|
@ -3,4 +3,3 @@ usr/include
|
|||
usr/lib/*/pkgconfig/*.pc
|
||||
usr/lib/*/cmake/*/*.cmake
|
||||
usr/lib/*/qt5/*
|
||||
usr/lib/*/libdtk/modules/*
|
||||
|
|
|
@ -1,9 +1,2 @@
|
|||
TEMPLATE = subdirs
|
||||
include($$PWD/src/dtk_lib.prf)
|
||||
|
||||
CONFIG += ordered
|
||||
|
||||
SUBDIRS += \
|
||||
src \
|
||||
tests
|
||||
|
||||
!mac:!win*: SUBDIRS += tools
|
||||
|
|
|
@ -77,3 +77,7 @@ isEmpty(includes.path): includes.path = $$quote($$DTK_INCLUDEPATH/D$$upper($$mem
|
|||
DEFINES += DTK_STATIC_LIB
|
||||
CONFIG += staticlib
|
||||
}
|
||||
|
||||
!isEmpty(DTK_STATIC_TRANSLATION) {
|
||||
DEFINES += DTK_STATIC_TRANSLATION
|
||||
}
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
exists($$_PRO_FILE_PWD_/src/dtk_translation.prf) {
|
||||
include($$_PRO_FILE_PWD_/src/dtk_translation.prf)
|
||||
} else {
|
||||
load(dtk_translation)
|
||||
}
|
||||
|
||||
TEMPLATE = subdirs
|
||||
CONFIG += ordered
|
||||
|
||||
exists($$_PRO_FILE_PWD_/src) SUBDIRS += src
|
||||
exists($$_PRO_FILE_PWD_/tools) SUBDIRS += tools
|
||||
exists($$_PRO_FILE_PWD_/tests) SUBDIRS += tests
|
||||
exists($$_PRO_FILE_PWD_/examples) SUBDIRS += examples
|
|
@ -3,17 +3,6 @@ isEmpty(DTK_MODULE): error("DTK_MODULE must not empty")
|
|||
isEmpty(includes.path): error("includes.path must not empty, please load(dtk_build) first!")
|
||||
isEmpty(target.path): error("target.path must not empty, , please load(dtk_build) first!")
|
||||
|
||||
|
||||
# -----------------------
|
||||
# Config pkg-config
|
||||
QMAKE_PKGCONFIG_VERSION = $$VERSION
|
||||
QMAKE_PKGCONFIG_DESTDIR = pkgconfig
|
||||
QMAKE_PKGCONFIG_NAME = DTK_$$upper($$replace(TARGET, "dtk", ""))
|
||||
QMAKE_PKGCONFIG_DESCRIPTION = Deepin Tool Kit $$TARGET header files
|
||||
QMAKE_PKGCONFIG_INCDIR = $$includes.path
|
||||
QMAKE_PKGCONFIG_LIBDIR = $$target.path
|
||||
|
||||
|
||||
# -----------------------
|
||||
# Config Qt module
|
||||
MODULE_ID=$$DTK_MODULE
|
||||
|
@ -21,6 +10,7 @@ mod_inst_pfx=$$_PRO_FILE_PWD_
|
|||
MODULE_PRI = $$mod_inst_pfx/qt_lib_$${MODULE_ID}.pri
|
||||
module_libs = $$target.path
|
||||
MODULE_INCLUDES = $$includes.path
|
||||
DTK_MODULE_DEPENDS=$$find(QT, dtk*)
|
||||
|
||||
message("config qt module: $$MODULE_ID")
|
||||
message("write $$MODULE_PRI to: $$mod_inst_pfx")
|
||||
|
@ -107,3 +97,29 @@ qt_module.files = $$MODULE_PRI
|
|||
qt_module.path = $${QT_HOST_DATA}/mkspecs/modules
|
||||
|
||||
INSTALLS += qt_module
|
||||
|
||||
|
||||
# -----------------------
|
||||
# Config pkg-config
|
||||
QMAKE_PKGCONFIG_VERSION = $$VERSION
|
||||
QMAKE_PKGCONFIG_DESTDIR = pkgconfig
|
||||
QMAKE_PKGCONFIG_NAME = DTK_$$upper($$replace(TARGET, "dtk", ""))
|
||||
QMAKE_PKGCONFIG_DESCRIPTION = Deepin Tool Kit $$TARGET header files
|
||||
QMAKE_PKGCONFIG_REQUIRES += $$DTK_MODULE_DEPENDS
|
||||
QMAKE_PKGCONFIG_INCDIR = $$includes.path
|
||||
QMAKE_PKGCONFIG_LIBDIR = $$target.path
|
||||
|
||||
|
||||
# -----------------------
|
||||
# Config translations
|
||||
!isEmpty(DTK_STATIC_TRANSLATION) {
|
||||
QRC_PATH = $$mod_inst_pfx/../translations/$${TARGET}_translations.qrc
|
||||
RESOURCES += $$QRC_PATH
|
||||
}
|
||||
|
||||
TRANSLATIONS += $$mod_inst_pfx/.../translations/*
|
||||
|
||||
dtk_translations.path = $$PREFIX/share/$${TARGET}/translations
|
||||
dtk_translations.files = $$mod_inst_pfx/../translations/*.qm
|
||||
|
||||
INSTALLS += dtk_translations
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
message ("Process dtk translation")
|
||||
message ("Add DTK_NO_TRANSLATION=YES to qmake arguments skip this")
|
||||
message ("Add DTK_STATIC_TRANSLATION=YES to add support static translations")
|
||||
|
||||
# TODO: check lrelease/lupdate exist
|
||||
|
||||
ROOT_DIR = $$_PRO_FILE_PWD_
|
||||
|
||||
BASENAME = $$basename(_PRO_FILE_)
|
||||
BASENAME = $$split(BASENAME, .)
|
||||
BASENAME = $$first(BASENAME)
|
||||
|
||||
isEmpty(DTK_NO_TRANSLATION) {
|
||||
# system(lupdate $$_PRO_FILE_) | error("Failed to lupdate")
|
||||
|
||||
TRANSLATIONS = $$files($$ROOT_DIR/translations/*.ts)
|
||||
for(tsfile, TRANSLATIONS) {
|
||||
qmfile = $$replace(tsfile, .ts$, .qm)
|
||||
system(lrelease $$tsfile -qm $$qmfile) | error("Failed to lrelease")
|
||||
}
|
||||
|
||||
# create static translations qrc file
|
||||
!isEmpty(DTK_STATIC_TRANSLATION) {
|
||||
# qrc template
|
||||
#<RCC>
|
||||
# <qresource prefix="/dtk/translations">
|
||||
# <file>dtkwidget2_am_ET.qm</file>
|
||||
# <file>dtkwidget2_ar.qm</file>
|
||||
# <file>dtkwidget2_ast.qm</file>
|
||||
# </qresource>
|
||||
#</RCC>
|
||||
QRC_PATH = $$ROOT_DIR/translations/$${BASENAME}_translations.qrc
|
||||
message ("Create static translations file $${QRC_PATH}")
|
||||
|
||||
QRC_CONTENT = "<RCC>"
|
||||
QRC_CONTENT += " <qresource prefix=\"/dtk/translations\">"
|
||||
|
||||
QM_FILE_LIST = $$files($$ROOT_DIR/translations/*.qm)
|
||||
for(qmfile, QM_FILE_LIST) {
|
||||
QRC_CONTENT += " <file>$$basename(qmfile)</file>"
|
||||
}
|
||||
QRC_CONTENT += " </qresource>"
|
||||
QRC_CONTENT += "</RCC>"
|
||||
write_file($$QRC_PATH, QRC_CONTENT) | error("Aborting.")
|
||||
}
|
||||
}
|
14
src/src.pro
14
src/src.pro
|
@ -82,22 +82,10 @@ INSTALLS += includes target
|
|||
|
||||
#cmake
|
||||
include(dtk_cmake.prf)
|
||||
|
||||
#qt module
|
||||
include(dtk_module.prf)
|
||||
|
||||
prf.files+= $$PWD/*.prf
|
||||
prf.path = $${QT_HOST_DATA}/mkspecs/features
|
||||
INSTALLS += prf
|
||||
|
||||
# -----------------------------------------------
|
||||
# TODO: remove this, replace with dtk_build
|
||||
|
||||
pri_dev.files += $$PWD/version.pri
|
||||
|
||||
isEmpty(LIB_INSTALL_DIR) {
|
||||
pri_dev.path = $$PREFIX/lib/libdtk/modules
|
||||
} else {
|
||||
pri_dev.path = $$LIB_INSTALL_DIR/libdtk/modules
|
||||
}
|
||||
|
||||
INSTALLS += pri_dev
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
TEMPLATE = subdirs
|
||||
|
||||
CONFIG += ordered
|
||||
|
||||
SUBDIRS += \
|
||||
settings \
|
||||
!mac:!win*: SUBDIRS += settings
|
||||
|
|
Loading…
Reference in New Issue