author | sheepluva |
Sat, 12 Sep 2015 20:01:26 +0200 | |
branch | gettext |
changeset 11168 | e104e060911b |
parent 10388 | 665d8b699d35 |
child 11172 | db1d14179b6c |
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 |
|
11168 | 12 |
#QT4_ADD_TRANSLATION(QM ${tsfiles}) |
3822 | 13 |
|
11168 | 14 |
set(qtpro "${PROJECT_SOURCE_DIR}/project_files/hedgewars.pro") |
15 |
||
16 |
add_custom_target(release-translation-qt |
|
17 |
COMMAND ${QT_LRELEASE_EXECUTABLE} -silent ${qtpro} |
|
8443 | 18 |
COMMENT "Compiling ts files" |
3822 | 19 |
) |
1026 | 20 |
|
11168 | 21 |
file(GLOB pofiles *.po) |
22 |
||
23 |
string(REGEX REPLACE "(^|;)[^;]*/([^/]+).po($|;)" "\\1${CMAKE_CURRENT_BINARY_DIR}/\\2.mo\\3" mofiles "${pofiles}") |
|
24 |
||
25 |
add_custom_target(release-translation-lua |
|
26 |
DEPENDS ${pofiles} |
|
27 |
COMMENT "Compiling po files" |
|
28 |
) |
|
29 |
||
30 |
# compile all the pofiles |
|
31 |
foreach(pofile ${pofiles}) |
|
32 |
||
33 |
string(REGEX REPLACE "^.*/([^/]+).po" "\\1.mo" mofile ${pofile}) |
|
34 |
||
35 |
# add_custom_command(OUTPUT ${mofile} |
|
36 |
add_custom_command(TARGET release-translation-lua |
|
37 |
#COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} "--statistics" "--output=${mofile}" ${pofile} |
|
38 |
COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} "--output=${mofile}" ${pofile} |
|
39 |
#DEPENDS ${pofile} |
|
40 |
# COMMENT "Compiling po file ${mofile}" |
|
41 |
) |
|
42 |
||
43 |
endforeach(pofile) |
|
44 |
||
45 |
add_custom_target(release-translation ALL |
|
46 |
DEPENDS release-translation-qt release-translation-lua |
|
47 |
) |
|
48 |
||
49 |
||
50 |
||
51 |
if(UPDATE_TRANSLATIONS) |
|
52 |
# lua |
|
53 |
set(loctemplate "messages.pot") |
|
54 |
#set(luasearchroot "${PROJECT_SOURCE_DIR}/share/hedgewars/Data") |
|
55 |
set(luasearchroot "..") |
|
56 |
||
57 |
set(poargs |
|
58 |
"--no-wrap" |
|
59 |
"--add-location" |
|
60 |
"--sort-by-file" |
|
61 |
) |
|
62 |
||
63 |
# make sure to pass relative paths |
|
64 |
file(GLOB_RECURSE luafiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${luasearchroot}/*.lua") |
|
65 |
||
66 |
add_custom_command(OUTPUT ${loctemplate} |
|
67 |
COMMAND "xgettext" |
|
68 |
"--output=${CMAKE_CURRENT_BINARY_DIR}/${loctemplate}" |
|
69 |
"--from-code=UTF-8" |
|
70 |
"-k" "--keyword=loc" |
|
71 |
${poargs} |
|
72 |
#"--add-comments=@loc" |
|
73 |
${luafiles} |
|
74 |
DEPENDS ${luafiles} |
|
75 |
# since we're using relative paths we need to work from within the source dir |
|
76 |
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} |
|
77 |
COMMENT "Creating po template" |
|
78 |
) |
|
79 |
||
80 |
add_custom_target(update-translation-lua |
|
81 |
COMMENT "Updating po files" |
|
82 |
DEPENDS ${loctemplate} |
|
83 |
) |
|
84 |
||
85 |
# merge template with existing PO files |
|
86 |
foreach(pofile ${pofiles}) |
|
87 |
add_custom_command(TARGET update-translation-lua |
|
88 |
COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} "--quiet" "--update" "--backup=off" ${poargs} ${pofile} ${loctemplate} |
|
89 |
#COMMENT "Updating file ${pofile}" |
|
90 |
) |
|
91 |
endforeach(pofile) |
|
92 |
||
93 |
add_dependencies(release-translation-lua update-translation-lua) |
|
94 |
||
95 |
# qt |
|
96 |
set(svrmsgsfile "${CMAKE_SOURCE_DIR}/QTfrontend/servermessages.h") |
|
97 |
||
98 |
if(NOT EXISTS ${svrmsgsfile}) |
|
99 |
message(WARNING "\n" |
|
100 |
"${svrmsgs} not found.\n" |
|
101 |
"It is required for a proper QT translation files update!\n" |
|
102 |
"\n" |
|
103 |
"This is normal for out-of-dir builds.\n" |
|
104 |
"Make a symlink to the file in the build-dir.\n" |
|
105 |
) |
|
106 |
endif() |
|
107 |
||
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 |