author | sheepluva |
Mon, 02 Nov 2015 06:23:46 +0100 | |
branch | gettext |
changeset 11172 | db1d14179b6c |
parent 11168 | e104e060911b |
permissions | -rw-r--r-- |
10388
665d8b699d35
part of patch in issue 803 (ty) - this hopefully should fix issues with cmake Makefiles trying to run "Qt4::lrelease" in the shell
sheepluva
parents:
9832
diff
changeset
|
1 |
find_package(Qt4 REQUIRED) |
665d8b699d35
part of patch in issue 803 (ty) - this hopefully should fix issues with cmake Makefiles trying to run "Qt4::lrelease" in the shell
sheepluva
parents:
9832
diff
changeset
|
2 |
include(${QT_USE_FILE}) |
11168 | 3 |
find_package(Gettext REQUIRED) |
10388
665d8b699d35
part of patch in issue 803 (ty) - this hopefully should fix issues with cmake Makefiles trying to run "Qt4::lrelease" in the shell
sheepluva
parents:
9832
diff
changeset
|
4 |
|
1993 | 5 |
file(GLOB txttrans2 ??.txt) |
6 |
file(GLOB txttrans5 ?????.txt) |
|
3822 | 7 |
file(GLOB tsfiles *.ts) |
6059 | 8 |
file(GLOB missionfiles missions_*.txt) |
9237
b2f4bd758a0b
added campaign descriptions in CMakeList
Periklis Ntanasis <pntanasis@gmail.com>
parents:
8443
diff
changeset
|
9 |
file(GLOB campaignfiles campaigns_*.txt) |
9832
b1038b4373cc
Localise tips again. Including new german contribution from bug #738. We should look into the old .ts files and see if there are translations that can be recovered.
nemo
parents:
9237
diff
changeset
|
10 |
file(GLOB tipfiles tips_*.xml) |
3822 | 11 |
|
11172
db1d14179b6c
silent qm-compile did not play well with out-of-source building
sheepluva
parents:
11168
diff
changeset
|
12 |
QT4_ADD_TRANSLATION(QM ${tsfiles}) |
11168 | 13 |
|
14 |
add_custom_target(release-translation-qt |
|
11172
db1d14179b6c
silent qm-compile did not play well with out-of-source building
sheepluva
parents:
11168
diff
changeset
|
15 |
DEPENDS ${QM} |
8443 | 16 |
COMMENT "Compiling ts files" |
3822 | 17 |
) |
1026 | 18 |
|
11168 | 19 |
file(GLOB pofiles *.po) |
20 |
||
21 |
string(REGEX REPLACE "(^|;)[^;]*/([^/]+).po($|;)" "\\1${CMAKE_CURRENT_BINARY_DIR}/\\2.mo\\3" mofiles "${pofiles}") |
|
22 |
||
23 |
add_custom_target(release-translation-lua |
|
24 |
DEPENDS ${pofiles} |
|
25 |
COMMENT "Compiling po files" |
|
26 |
) |
|
27 |
||
28 |
# compile all the pofiles |
|
29 |
foreach(pofile ${pofiles}) |
|
30 |
||
31 |
string(REGEX REPLACE "^.*/([^/]+).po" "\\1.mo" mofile ${pofile}) |
|
32 |
||
33 |
# add_custom_command(OUTPUT ${mofile} |
|
34 |
add_custom_command(TARGET release-translation-lua |
|
35 |
#COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} "--statistics" "--output=${mofile}" ${pofile} |
|
36 |
COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} "--output=${mofile}" ${pofile} |
|
37 |
#DEPENDS ${pofile} |
|
38 |
# COMMENT "Compiling po file ${mofile}" |
|
39 |
) |
|
40 |
||
41 |
endforeach(pofile) |
|
42 |
||
43 |
add_custom_target(release-translation ALL |
|
44 |
DEPENDS release-translation-qt release-translation-lua |
|
45 |
) |
|
46 |
||
47 |
||
48 |
||
49 |
if(UPDATE_TRANSLATIONS) |
|
50 |
# lua |
|
51 |
set(loctemplate "messages.pot") |
|
52 |
#set(luasearchroot "${PROJECT_SOURCE_DIR}/share/hedgewars/Data") |
|
53 |
set(luasearchroot "..") |
|
54 |
||
55 |
set(poargs |
|
56 |
"--no-wrap" |
|
57 |
"--add-location" |
|
58 |
"--sort-by-file" |
|
59 |
) |
|
60 |
||
61 |
# make sure to pass relative paths |
|
62 |
file(GLOB_RECURSE luafiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${luasearchroot}/*.lua") |
|
63 |
||
64 |
add_custom_command(OUTPUT ${loctemplate} |
|
65 |
COMMAND "xgettext" |
|
66 |
"--output=${CMAKE_CURRENT_BINARY_DIR}/${loctemplate}" |
|
67 |
"--from-code=UTF-8" |
|
68 |
"-k" "--keyword=loc" |
|
69 |
${poargs} |
|
70 |
#"--add-comments=@loc" |
|
71 |
${luafiles} |
|
72 |
DEPENDS ${luafiles} |
|
73 |
# since we're using relative paths we need to work from within the source dir |
|
74 |
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} |
|
75 |
COMMENT "Creating po template" |
|
76 |
) |
|
77 |
||
78 |
add_custom_target(update-translation-lua |
|
79 |
COMMENT "Updating po files" |
|
80 |
DEPENDS ${loctemplate} |
|
81 |
) |
|
82 |
||
83 |
# merge template with existing PO files |
|
84 |
foreach(pofile ${pofiles}) |
|
85 |
add_custom_command(TARGET update-translation-lua |
|
86 |
COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} "--quiet" "--update" "--backup=off" ${poargs} ${pofile} ${loctemplate} |
|
87 |
#COMMENT "Updating file ${pofile}" |
|
88 |
) |
|
89 |
endforeach(pofile) |
|
90 |
||
91 |
add_dependencies(release-translation-lua update-translation-lua) |
|
92 |
||
93 |
# qt |
|
94 |
set(svrmsgsfile "${CMAKE_SOURCE_DIR}/QTfrontend/servermessages.h") |
|
95 |
||
96 |
if(NOT EXISTS ${svrmsgsfile}) |
|
97 |
message(WARNING "\n" |
|
98 |
"${svrmsgs} not found.\n" |
|
99 |
"It is required for a proper QT translation files update!\n" |
|
100 |
"\n" |
|
101 |
"This is normal for out-of-dir builds.\n" |
|
102 |
"Make a symlink to the file in the build-dir.\n" |
|
103 |
) |
|
104 |
endif() |
|
105 |
||
11172
db1d14179b6c
silent qm-compile did not play well with out-of-source building
sheepluva
parents:
11168
diff
changeset
|
106 |
set(qtpro "${PROJECT_SOURCE_DIR}/project_files/hedgewars.pro") |
db1d14179b6c
silent qm-compile did not play well with out-of-source building
sheepluva
parents:
11168
diff
changeset
|
107 |
|
11168 | 108 |
add_custom_target(update-translation-qt |
109 |
COMMAND ${QT_LUPDATE_EXECUTABLE} -silent -locations absolute -pro ${qtpro} |
|
110 |
DEPENDS ${svrmsgsfile} |
|
111 |
COMMENT "Updating ts files" |
|
112 |
) |
|
113 |
||
114 |
add_dependencies(release-translation-qt update-translation-qt) |
|
115 |
||
116 |
endif(UPDATE_TRANSLATIONS) |
|
117 |
||
118 |
||
119 |
||
120 |
#install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} DESTINATION "${SHAREPATH}Data" |
|
121 |
# FILES_MATCHING PATTERN "*.mo" |
|
122 |
# PATTERN "*/CMakeFiles" EXCLUDE |
|
123 |
#) |
|
124 |
||
125 |
#file(GLOB luafiles *.lua) |
|
126 |
||
184 | 127 |
install(FILES |
11168 | 128 |
${mofiles} |
129 |
#${luafiles} |
|
8443 | 130 |
${txttrans2} |
131 |
${txttrans5} |
|
132 |
${QM} |
|
133 |
${missionfiles} |
|
9237
b2f4bd758a0b
added campaign descriptions in CMakeList
Periklis Ntanasis <pntanasis@gmail.com>
parents:
8443
diff
changeset
|
134 |
${campaignfiles} |
9832
b1038b4373cc
Localise tips again. Including new german contribution from bug #738. We should look into the old .ts files and see if there are translations that can be recovered.
nemo
parents:
9237
diff
changeset
|
135 |
${tipfiles} |
11168 | 136 |
DESTINATION "${SHAREPATH}Data/Locale" |
3822 | 137 |
) |
138 |