-
Notifications
You must be signed in to change notification settings - Fork 24
/
translations.pri
39 lines (35 loc) · 1.2 KB
/
translations.pri
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Supported languages
## **Add new .qm to translations.qrc**
## **Update translations.cpp**
LANGUAGES = en fr de es
TRANSLATIONS_DIR = $${_PRO_FILE_PWD_}/translations
SOURCES += \
$${TRANSLATIONS_DIR}/translationdialog.cpp \
$${TRANSLATIONS_DIR}/translations.cpp
HEADERS += \
$${TRANSLATIONS_DIR}/translationdialog.h \
$${TRANSLATIONS_DIR}/translations.h
FORMS += \
$${TRANSLATIONS_DIR}/translationdialog.ui
RESOURCES += \
$${TRANSLATIONS_DIR}/translations.qrc
# Create/update .ts Files
qtPrepareTool(LUPDATE, lupdate)
command = $$LUPDATE -no-obsolete $$shell_quote($$_PRO_FILE_)
system($$command)|error("Failed to run: $$command")
## https://appbus.wordpress.com/2016/04/28/howto-translations-i18n/
# Available translations
defineReplace(prependAll) {
for(a,$$1):result += $$2$${a}$$3
return($$result)
}
tsroot = $$join(TARGET,,,.ts)
tstarget = $$join(TARGET,,,_)
TRANSLATIONS = $${TRANSLATIONS_DIR}/$$tsroot
TRANSLATIONS += $$prependAll(LANGUAGES, $${TRANSLATIONS_DIR}/$$tstarget, .ts)
# run LRELEASE to generate the qm files
qtPrepareTool(LRELEASE, lrelease)
for(tsfile, TRANSLATIONS) {
command = $$LRELEASE $$shell_quote($$tsfile)
system($$command)|error("Failed to run: $$command")
}