~verzegnassi-stefano/ubuntu-docviewer-app/lo-plugin-prototype

« back to all changes in this revision

Viewing changes to po/CMakeLists.txt

  • Committer: Bartosz Kosiorek
  • Date: 2015-01-24 00:03:13 UTC
  • mto: This revision was merged to the branch mainline in revision 52.
  • Revision ID: gang65@poczta.onet.pl-20150124000313-a71s61szi1yijvth
Introduce translation support for DocViewer

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
include(FindGettext)
 
2
 
 
3
# Find the translation tools
 
4
find_program(INTLTOOL_MERGE intltool-merge)
 
5
if(NOT INTLTOOL_MERGE)
 
6
  message(FATAL_ERROR "Could not find intltool-merge, please install the intltool package")
 
7
endif()
 
8
 
 
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")
 
12
endif()
 
13
 
 
14
find_program(GETTEXT_XGETTEXT_EXECUTABLE xgettext)
 
15
 
 
16
set(DOMAIN ${PROJECT_NAME})
 
17
set(POT_FILE ${DOMAIN}.pot)
 
18
file(GLOB PO_FILES *.po)
 
19
 
 
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}
 
28
          --from-code=UTF-8
 
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} 
 
34
          ${I18N_SRC_FILES}
 
35
  # Copy the up2date translation file to the source directory
 
36
  COMMAND ${CMAKE_COMMAND} -E copy ${POT_FILE} ${CMAKE_CURRENT_SOURCE_DIR}
 
37
)
 
38
 
 
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}
 
47
  RENAME ${DOMAIN}.mo)
 
48
endforeach(PO_FILE)
 
49
 
 
50
 
 
51
# make the translation files visible on qtcreator
 
52
file(GLOB TRANSLATION_FILES
 
53
     RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
 
54
     *.po *.pot)
 
55
 
 
56
add_custom_target(com_ubuntu_docviewer_translation_files ALL SOURCES ${TRANSLATION_FILES})
 
57