3
# Find the translation tools
4
find_program(INTLTOOL_MERGE intltool-merge)
6
message(FATAL_ERROR "Could not find intltool-merge, please install the intltool package")
9
find_program(INTLTOOL_EXTRACT intltool-extract)
10
if(NOT INTLTOOL_EXTRACT)
11
message(FATAL_ERROR "Could not find intltool-extract, please install the intltool package")
14
find_program(GETTEXT_XGETTEXT_EXECUTABLE xgettext)
16
set(DOMAIN ${PROJECT_NAME})
17
set(POT_FILE ${DOMAIN}.pot)
18
file(GLOB PO_FILES *.po)
20
# Creates the .pot file containing the translations template
21
add_custom_target(${POT_FILE} ALL
22
COMMENT "Generating translation template"
23
# Extract the translatable messages from the desktop file
24
COMMAND ${INTLTOOL_EXTRACT} --update --type=gettext/ini
25
--srcdir=${CMAKE_SOURCE_DIR} ${DESKTOP_FILE}.in.in
26
# Update the translation file
27
COMMAND ${GETTEXT_XGETTEXT_EXECUTABLE} -o ${POT_FILE}
29
--c++ --qt --add-comments=TRANSLATORS
30
--keyword=tr --keyword=tr:1,2 --keyword=N_
31
--package-name='${PROJECT}'
32
--copyright-holder='Canonical Ltd.'
33
--directory ${CMAKE_CURRENT_SOURCE_DIR}
35
# Copy the up2date translation file to the source directory
36
COMMAND ${CMAKE_COMMAND} -E copy ${POT_FILE} ${CMAKE_CURRENT_SOURCE_DIR}
39
# Builds the binary translations catalog. For each language
40
# it finds source translations (*.po) for generating mo files
41
foreach(PO_FILE ${PO_FILES})
42
get_filename_component(LANG ${PO_FILE} NAME_WE)
43
gettext_process_po_files(${LANG} ALL PO_FILES ${PO_FILE})
44
set(INSTALL_DIR ${CMAKE_INSTALL_LOCALEDIR}/${LANG}/LC_MESSAGES)
45
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${LANG}.gmo
46
DESTINATION ${INSTALL_DIR}
51
# make the translation files visible on qtcreator
52
file(GLOB TRANSLATION_FILES
53
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
56
add_custom_target(com_ubuntu_docviewer_translation_files ALL SOURCES ${TRANSLATION_FILES})