/
translations.pri
174 lines (160 loc) · 6.14 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# This include file makes generation and installation of .qm files
# from .ts files and updating .ts files from the sources easier.
#
# An application which has translations can use this include file as
# in the following example for “widgetsgallery”:
#
# Create a subdirectory “translations” in the source folder of the
# application which contains a translations.po file and the .ts
# files, for example if the source dir is “libm/demos/widgetsgallery”:
#
# libm/demos/widgetsgallery/translations.pro
# libm/demos/widgetsgallery/widgetsgallery_ar.ts
# libm/demos/widgetsgallery/widgetsgallery_de.ts
# libm/demos/widgetsgallery/widgetsgallery_en.ts
# libm/demos/widgetsgallery/widgetsgallery_fi.ts
#
# The translations.pro file should have contents like this:
#
# LANGUAGES = ar de en fi
# CATALOGNAME = widgetsgallery
# SOURCEDIR = $$PWD/..
# TRANSLATIONDIR = $$PWD
# MROOT = ../../..
# include($$MROOT/mconfig.pri)
# include($$MROOT/translations.pri)
#
# It is better to have an extra translations.pro file in the directory
# where the translations are instead of adding the stuff for the translations
# to the .pro file of the application (“widgetsgallery.pro”).
# It is possible to add similar stuff to update the .qm files
# directly to the application profile but the disadvantage is that
# changing the .ts files then causes the application to rebuild
# (because of qmake limitations).
#
# Introducing the extra translations/translations.pro file makes it
# necessary to add the widgetsgallery/translations directory to the
# list of sub-directories in a .pro file higher up in the directory
# hierarchy. For example the libm/demos/demos.pro file contains
# something like the following:
#
# SUBDIRS = \
# servicefw \
# widgetsgallery \
# widgetsgallery/translations \
# animatedlayout \
# animatedlayout/translations \
# launcher \
# qtstyleexample
#
# get around lack of sleep on Windows:
unix:SLEEP = sleep 1
else:SLEEP = ping -n 5 localhost > NUL
# null device:
unix:NULL = /dev/null
else:NULL = NUL
# var, prepend, append
defineReplace(prependAll) {
for(a,$$1):result += $$2$${a}$$3
return($$result)
}
isEmpty(LRELEASE_OPTIONS) {
LRELEASE_OPTIONS = -idbased
}
isEmpty(LUPDATE_OPTIONS) {
LUPDATE_OPTIONS = -locations absolute -no-ui-lines -no-sort
}
defineReplace(targetPath) {
return($$replace(1, /, $$QMAKE_DIR_SEP))
}
LRELEASE = $$targetPath($$[QT_INSTALL_BINS]/lrelease) $$LRELEASE_OPTIONS
LUPDATE = $$targetPath($$[QT_INSTALL_BINS]/lupdate) $$LUPDATE_OPTIONS
# add “-markuntranslated '!!\ '” if available (needs new Qt 4.6):
out = $$system($$LRELEASE -help)
# the second parameter of contains can be a regexp!
contains(out, .*markuntranslated.*) {
LRELEASE += -markuntranslated '!!\ '
}
TRANSLATIONS = $$prependAll(LANGUAGES, $$TRANSLATIONDIR/$${CATALOGNAME}_,.ts)
isEqual(TEMPLATE_PREFIX, vc):vcproj=1
isEmpty(vcproj) {
QMAKE_LINK = @: IGNORE THIS LINE
OBJECTS_DIR =
win32:CONFIG -= embed_manifest_exe
} else {
CONFIG += console
PHONY_DEPS = .
phony_src.input = PHONY_DEPS
phony_src.output = phony.c
phony_src.variable_out = GENERATED_SOURCES
phony_src.commands = echo int main() { return 0; } > phony.c
phony_src.name = CREATE phony.c
phony_src.CONFIG += combine
QMAKE_EXTRA_COMPILERS += phony_src
}
!isEqual(DISABLE_QTTRID_ENGINEERING_ENGLISH, "yes") {
ENGINEERING_ENGLISH = $$OUT_PWD/$${CATALOGNAME}.ts
# updating the engineering English .ts file should be done *always*
# because it is fully auto-generated, no manual editing is needed:
DUMMY_DEP = $$OUT_PWD/dummy-dependency-this-file-will-never-be-created
updateeets.input = DUMMY_DEP
updateeets.output = $$ENGINEERING_ENGLISH
!isEmpty(vcproj):updateeets.variable_out = GENERATED_SOURCES
updateeets.commands = $$LUPDATE $$SOURCEDIR -ts $$ENGINEERING_ENGLISH
updateeets.name = LUPDATE $$ENGINEERING_ENGLISH
updateeets.CONFIG += no_link target_predeps
QMAKE_EXTRA_COMPILERS += updateeets
FORCED_DEP = .
dummy.input = FORCED_DEP
dummy.output = $$DUMMY_DEP
!isEmpty(vcproj):dummy.variable_out = GENERATED_SOURCES
# we do not really create $$DUMMY_DEP here, make does not check the
# output of the build steps, it assumes that the build command either
# fails or that the output is created:
dummy.commands = echo > $$NULL
dummy.CONFIG += no_link target_predeps
QMAKE_EXTRA_COMPILERS += dummy
}
# the stuff below works as well on Linux, but does not work with vcproj
# because PRE_TARGETDEPS (just like .CONFIG += target_predeps) does
# not work for vcproj output.
#
# !isEqual(DISABLE_QTTRID_ENGINEERING_ENGLISH, "yes") {
# ENGINEERING_ENGLISH = $$OUT_PWD/$${CATALOGNAME}.ts
# # updating the engineering English .ts file should be done *always*
# # because it is fully auto-generated, no manual editing is needed:
#
# updateeets.commands = $$LUPDATE $$SOURCEDIR -ts $$ENGINEERING_ENGLISH
# QMAKE_EXTRA_TARGETS += updateeets
# QMAKE_CLEAN += $$ENGINEERING_ENGLISH
# PRE_TARGETDEPS = updateeets
# }
# other .ts files besides the engineering English one should only be updated
# on request, i.e. only when calling “make updatets” manually:
updatets.commands = $$LUPDATE $$SOURCEDIR -ts $$TRANSLATIONS
updatets.target = updatets
QMAKE_EXTRA_TARGETS += updatets
updateqm.input = TRANSLATIONS
!isEqual(DISABLE_QTTRID_ENGINEERING_ENGLISH, "yes") {
updateqm.input += ENGINEERING_ENGLISH
}
updateqm.output = $$OUT_PWD/${QMAKE_FILE_BASE}.qm
updateqm.commands = $$LRELEASE ${QMAKE_FILE_IN} -qm ${QMAKE_FILE_OUT};
updateqm.name = LRELEASE ${QMAKE_FILE_IN}
updateqm.CONFIG += no_link target_predeps
QMAKE_EXTRA_COMPILERS += updateqm
isEqual(INSTALL_TRANSLATIONS, "no") {
# do not install the .qm files
}
else {
isEmpty(TRANSLATION_INSTALLDIR) {
TRANSLATION_INSTALLDIR = $${M_TRANSLATION_DIR}
}
qmfiles.files = $$prependAll(LANGUAGES, $$OUT_PWD/$${CATALOGNAME}_,.qm)
!isEqual(DISABLE_QTTRID_ENGINEERING_ENGLISH, "yes") {
qmfiles.files += $$OUT_PWD/$${CATALOGNAME}.qm
}
qmfiles.CONFIG += no_check_exist
qmfiles.path = $${TRANSLATION_INSTALLDIR}
INSTALLS += qmfiles
}