~unity8-desktop-session-team/indicator-session/indicator-session-using-upstart

384.2.6 by Charles Kerr
Add Translations.cmake for i18n files
1
# Translations.cmake, CMake macros written for Marlin, feel free to re-use them
2
3
macro(add_translations_directory NLS_PACKAGE)
384.2.43 by Charles Kerr
copyediting: the COMMENT in this custom target was being misformatted in the make output
4
    add_custom_target (i18n ALL)
384.2.6 by Charles Kerr
Add Translations.cmake for i18n files
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
384.2.98 by Charles Kerr
in cmake/Translations.cmake, use the GNUInstallDirs variables
13
            ${CMAKE_INSTALL_LOCALEDIR}/LC_MESSAGES
384.2.6 by Charles Kerr
Add Translations.cmake for i18n files
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_RECURSE 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_RECURSE 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="_" --keyword="N_" --from-code=UTF-8
40
        )
41
endmacro()