~voldyman/pantheon-terminal/open-link-menu

« back to all changes in this revision

Viewing changes to cmake/Translations.cmake

  • Committer: Mario Guerriero
  • Date: 2011-12-05 20:27:31 UTC
  • Revision ID: mefrio.g@gmail.com-20111205202731-v6d3hi3ey0lvfmvx
fixed cmake configu file and added the support to gettext

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Translations.cmake, CMake macros written for Marlin, feel free to re-use them
 
2
 
 
3
macro(add_translations_directory NLS_PACKAGE)
 
4
    add_custom_target (i18n ALL COMMENT “Building i18n messages.”)
 
5
    find_program (MSGFMT_EXECUTABLE msgfmt)
 
6
    file (GLOB PO_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.po)
 
7
    foreach (PO_INPUT ${PO_FILES})
 
8
        get_filename_component (PO_INPUT_BASE ${PO_INPUT} NAME_WE)
 
9
        set (MO_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${PO_INPUT_BASE}.mo)
 
10
        add_custom_command (TARGET i18n COMMAND ${MSGFMT_EXECUTABLE} -o ${MO_OUTPUT} ${PO_INPUT})
 
11
 
 
12
        install (FILES ${MO_OUTPUT} DESTINATION
 
13
            share/locale/${PO_INPUT_BASE}/LC_MESSAGES
 
14
            RENAME ${NLS_PACKAGE}.mo)
 
15
    endforeach (PO_INPUT ${PO_FILES})
 
16
endmacro(add_translations_directory)
 
17
 
 
18
 
 
19
macro(add_translations_catalog NLS_PACKAGE)
 
20
    add_custom_target (pot COMMENT “Building translation catalog.”)
 
21
    find_program (XGETTEXT_EXECUTABLE xgettext)
 
22
 
 
23
 
 
24
    set(C_SOURCE "")
 
25
 
 
26
    foreach(FILES_INPUT ${ARGN})
 
27
        file (GLOB SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/${FILES_INPUT}/*.c)
 
28
        foreach(C_FILE ${SOURCE_FILES})
 
29
            set(C_SOURCE ${C_SOURCE} ${C_FILE})
 
30
        endforeach()
 
31
        file (GLOB SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/${FILES_INPUT}/*.vala)
 
32
        foreach(C_FILE ${SOURCE_FILES})
 
33
            set(C_SOURCE ${C_SOURCE} ${C_FILE})
 
34
        endforeach()
 
35
    endforeach()
 
36
 
 
37
    add_custom_command (TARGET pot COMMAND
 
38
        ${XGETTEXT_EXECUTABLE} -d ${NLS_PACKAGE} -o ${CMAKE_CURRENT_SOURCE_DIR}/${NLS_PACKAGE}.pot
 
39
        ${VALA_SOURCE} ${C_SOURCE} --keyword="_" --from-code=UTF-8
 
40
        )
 
41
endmacro()