~fboucault/machines-vs-machines/splash_fixes

« back to all changes in this revision

Viewing changes to po/CMakeLists.txt

  • Committer: Michael Zanetti
  • Date: 2015-01-04 17:18:56 UTC
  • Revision ID: michael.zanetti@canonical.com-20150104171856-a6qivfui7e3d00s2
update the cmakelists template to the latest sdk one

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
if(NOT CMAKE_INSTALL_LOCALEDIR)
 
15
 set(CMAKE_INSTALL_LOCALEDIR "share/locale")
 
16
endif()
 
17
 
 
18
find_program(GETTEXT_XGETTEXT_EXECUTABLE xgettext)
 
19
 
 
20
set(DOMAIN ${APP_ID})
 
21
set(POT_FILE ${DOMAIN}.pot)
 
22
file(GLOB PO_FILES *.po)
 
23
 
 
24
file(GLOB_RECURSE I18N_SRC_FILES
 
25
 RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
 
26
 ${CMAKE_SOURCE_DIR}/*.qml 
 
27
 ${CMAKE_SOURCE_DIR}/*.js 
 
28
 ${CMAKE_SOURCE_DIR}/*.cpp 
 
29
 ${CMAKE_SOURCE_DIR}/*.h
 
30
)
 
31
list(APPEND I18N_SRC_FILES ${CMAKE_CURRENT_BINARY_DIR}/${DESKTOP_FILE_NAME}.in.h)
 
32
list(SORT I18N_SRC_FILES)
 
33
 
 
34
add_custom_target(${POT_FILE} ALL
 
35
 COMMENT "Generating translation template"
 
36
 # Extract the translatable messages from the desktop file 
 
37
 COMMAND ${INTLTOOL_EXTRACT} --update --type=gettext/ini
 
38
 --srcdir=${CMAKE_BINARY_DIR}/app ${DESKTOP_FILE_NAME}.in
 
39
 # Update the translation file
 
40
 COMMAND ${GETTEXT_XGETTEXT_EXECUTABLE} -o ${POT_FILE}
 
41
 --from-code=UTF-8
 
42
 --c++ --qt --add-comments=TRANSLATORS
 
43
 --keyword=tr --keyword=tr:1,2 --keyword=N_
 
44
 --package-name='${PROJECT}'
 
45
 -D ${CMAKE_CURRENT_SOURCE_DIR} ${I18N_SRC_FILES}
 
46
 # Copy the up2date translation file to the source directory
 
47
 COMMAND ${CMAKE_COMMAND} -E copy ${POT_FILE} ${CMAKE_CURRENT_SOURCE_DIR}
 
48
)
 
49
 
 
50
foreach(PO_FILE ${PO_FILES})
 
51
 get_filename_component(LANG ${PO_FILE} NAME_WE)
 
52
 gettext_process_po_files(${LANG} ALL PO_FILES ${PO_FILE})
 
53
 set(INSTALL_DIR ${CMAKE_INSTALL_LOCALEDIR}/${LANG}/LC_MESSAGES)
 
54
 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${LANG}.gmo
 
55
 DESTINATION ${INSTALL_DIR}
 
56
 RENAME ${DOMAIN}.mo)
 
57
endforeach(PO_FILE)
 
58
 
 
59
add_custom_target(${DESKTOP_FILE_NAME} ALL
 
60
    COMMENT "Merging translations into ${DESKTOP_FILE_NAME}"
 
61
    COMMAND LC_ALL=C ${INTLTOOL_MERGE} -d -u ${CMAKE_SOURCE_DIR}/po ${CMAKE_BINARY_DIR}/app/${DESKTOP_FILE_NAME}.in ${CMAKE_BINARY_DIR}/app/${DESKTOP_FILE_NAME} > /dev/null
 
62
)
 
63