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
|
include(FindGettext)
find_program(GETTEXT_XGETTEXT_EXECUTABLE xgettext)
set(DOMAIN ${PROJECT_NAME})
set(POT_FILE ${DOMAIN}.pot)
file(GLOB PO_FILES *.po)
add_custom_target(${POT_FILE} ALL
COMMENT "Generating translation template"
COMMAND ${INTLTOOL_EXTRACT} --update --type=gettext/ini
--srcdir=${CMAKE_SOURCE_DIR} ${DESKTOP_FILE}.in.in
COMMAND ${GETTEXT_XGETTEXT_EXECUTABLE} -o ${POT_FILE}
-D ${CMAKE_CURRENT_SOURCE_DIR}
-D ${CMAKE_CURRENT_BINARY_DIR}
--from-code=UTF-8
--c++ --qt --add-comments=TRANSLATORS
--keyword=tr --keyword=tr:1,2 --keyword=N_
--package-name='${PROJECT}'
--copyright-holder='Canonical Ltd.'
${I18N_SRC_FILES}
COMMAND ${CMAKE_COMMAND} -E copy ${POT_FILE} ${CMAKE_CURRENT_SOURCE_DIR})
foreach(PO_FILE ${PO_FILES})
get_filename_component(LANG ${PO_FILE} NAME_WE)
gettext_process_po_files(${LANG} ALL PO_FILES ${PO_FILE})
set(INSTALL_DIR ${CMAKE_INSTALL_LOCALEDIR}/${LANG}/LC_MESSAGES)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${LANG}.gmo
DESTINATION ${INSTALL_DIR}
RENAME ${DOMAIN}.mo)
endforeach(PO_FILE)
|