1
TRANSLATIONS = $$files(*.ts)
2
3
qtPrepareTool(LRELEASE, lrelease)
4
qtPrepareTool(LCONVERT, lconvert)
5
qtPrepareTool(LUPDATE, lupdate)
6
LUPDATE += -locations relative -no-ui-lines
7
8
TS_TARGETS =
9
10
# meta target name, target name, lupdate base options, files
11
defineTest(addTsTarget) {
12
    cv = $${2}.commands
13
    $$cv = cd $$QT_SOURCE_TREE/src && $$LUPDATE $$3 -ts $$4
14
    export($$cv)
15
    dv = $${1}.depends
16
    $$dv += $$2
17
    export($$dv)
18
    TS_TARGETS += $$1 $$2
19
    export(TS_TARGETS)
20
}
21
22
# target basename, lupdate base options
23
defineTest(addTsTargets) {
24
    files = $$files($$PWD/$${1}_??.ts) $$files($$PWD/$${1}_??_??.ts)
25
    for(file, files) {
26
        lang = $$replace(file, .*_((.._)?..)\\.ts$, \\1)
27
        addTsTarget(ts-$$lang, ts-$$1-$$lang, $$2, $$file)
28
    }
29
    addTsTarget(ts-untranslated, ts-$$1-untranslated, $$2, $$PWD/$${1}_untranslated.ts)
30
    addTsTarget(ts-all, ts-$$1-all, $$2, $$PWD/$${1}_untranslated.ts $$files)
31
}
32
33
addTsTargets(qt, -I../include -I../include/Qt \
34
    3rdparty/phonon \
35
    3rdparty/webkit \
36
    activeqt \
37
    corelib \
38
    declarative \
39
    gui \
40
    multimedia \
41
    network \
42
    opengl \
43
    plugins \
44
    qt3support \
45
    script \
46
    scripttools \
47
    sql \
48
    svg \
49
    xml \
50
    xmlpatterns \
51
)
52
addTsTargets(designer, ../tools/designer/designer.pro)
53
addTsTargets(linguist, ../tools/linguist/linguist.pro)
54
addTsTargets(assistant, ../tools/assistant/tools/tools.pro)
55
addTsTargets(qt_help, ../tools/assistant/lib/lib.pro)
56
addTsTargets(qtconfig, ../tools/qtconfig/qtconfig.pro)
57
addTsTargets(qvfb, ../tools/qvfb/qvfb.pro)
58
addTsTargets(qmlviewer, ../tools/qml/qml.pro)
59
60
check-ts.commands = (cd $$PWD && perl check-ts.pl)
61
check-ts.depends = ts-all
62
63
isEqual(QMAKE_DIR_SEP, /) {
64
    commit-ts.commands = \
65
        cd $$PWD/..; \
66
        for f in `git diff-files --name-only translations/*_??.ts`; do \
67
            $$LCONVERT -locations none -i \$\$f -o \$\$f; \
68
        done; \
69
        git add translations/*_??.ts && git commit
70
} else {
71
    wd = $$replace(PWD, /, \\)\\..
72
    commit-ts.commands = \
73
        cd $$wd && \
74
        for /f usebackq %%f in (`git diff-files --name-only translations/*_??.ts`) do \
75
            $$LCONVERT -locations none -i %%f -o %%f $$escape_expand(\\n\\t) \
76
        cd $$wd && git add translations/*_??.ts && git commit
77
}
78
79
ts.commands = \
80
    @echo \"The \'ts\' target has been removed in favor of more fine-grained targets.\" && \
81
    echo \"Use \'ts-<target>-<lang>\' or \'ts-<lang>\' instead. To add a language,\" && \
82
    echo \"use \'untranslated\' for <lang>, rename the files and re-run \'qmake\'.\"
83
84
QMAKE_EXTRA_TARGETS += $$unique(TS_TARGETS) ts commit-ts check-ts
85
86
TEMPLATE = app
87
TARGET = qm_phony_target
88
CONFIG -= qt separate_debug_info gdb_dwarf_index sis_targets
89
CONFIG += no_icon
90
QT =
91
LIBS =
92
93
contains(TEMPLATE_PREFIX, vc):vcproj = 1
94
95
updateqm.input = TRANSLATIONS
96
updateqm.output = ${QMAKE_FILE_BASE}.qm
97
isEmpty(vcproj):updateqm.variable_out = PRE_TARGETDEPS
98
updateqm.commands = $$LRELEASE ${QMAKE_FILE_IN} -qm ${QMAKE_FILE_OUT}
99
silent:updateqm.commands = @echo lrelease ${QMAKE_FILE_IN} && $$updateqm.commands
100
updateqm.name = LRELEASE ${QMAKE_FILE_IN}
101
updateqm.CONFIG += no_link
102
QMAKE_EXTRA_COMPILERS += updateqm
103
104
isEmpty(vcproj) {
105
    QMAKE_LINK = @: IGNORE THIS LINE
106
    OBJECTS_DIR =
107
    win32:CONFIG -= embed_manifest_exe
108
} else {
109
    CONFIG += console
110
    PHONY_DEPS = .
111
    phony_src.input = PHONY_DEPS
112
    phony_src.output = phony.c
113
    phony_src.variable_out = GENERATED_SOURCES
114
    phony_src.commands = echo int main() { return 0; } > phony.c
115
    phony_src.name = CREATE phony.c
116
    phony_src.CONFIG += combine
117
    QMAKE_EXTRA_COMPILERS += phony_src
118
}
119
120
translations.path = $$[QT_INSTALL_TRANSLATIONS]
121
translations.files = $$TRANSLATIONS
122
translations.files ~= s,\\.ts$,.qm,g
123
translations.files ~= s,^,$$OUT_PWD/,g
124
translations.CONFIG += no_check_exist
125
INSTALLS += translations
126
127
# Make dummy "sis" target to keep recursive "make sis" working.
128
sis_target.target = sis
129
sis_target.commands =
130
QMAKE_EXTRA_TARGETS += sis_target