~writer-devs/writer/trunk

« back to all changes in this revision

Viewing changes to cmake/Translations.cmake

  • Committer: harp37 at gmail
  • Date: 2014-11-25 00:55:20 UTC
  • mto: This revision was merged to the branch mainline in revision 70.
  • Revision ID: harp37@gmail.com-20141125005520-6ax4j204vr1bby2i
CMake is nearly there.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
macro(add_translations_directory NLS_PACKAGE)
4
4
    add_custom_target (i18n ALL COMMENT “Building i18n messages.”)
5
5
    find_program (MSGFMT_EXECUTABLE msgfmt)
6
 
    # be sure that all languages are present
7
 
    set (LANGUAGES_NEEDED af am ar ast az be bg bn bs ca ckb cs da de el en_AU en_CA en_GB eo es et eu fa fi fr fr_CA gl he hi hr hu hy id it ja ka ko ky lb lo lt lv ml mr ms nb nl nn pl pt pt_BR ro ru rue si sk sl sma sq sr sv sw ta te th tr uk vi zh_CN zh_HK zh_TW)
8
 
    foreach (LANGUAGE_NEEDED ${LANGUAGES_NEEDED})
9
 
        if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LANGUAGE_NEEDED}.po)
10
 
            file (APPEND ${CMAKE_CURRENT_SOURCE_DIR}/${LANGUAGE_NEEDED}.po "msgid \"\"\n")
11
 
            file (APPEND ${CMAKE_CURRENT_SOURCE_DIR}/${LANGUAGE_NEEDED}.po "msgstr \"\"\n")
12
 
            file (APPEND ${CMAKE_CURRENT_SOURCE_DIR}/${LANGUAGE_NEEDED}.po "\"MIME-Version: 1.0\\n\"\n")
13
 
            file (APPEND ${CMAKE_CURRENT_SOURCE_DIR}/${LANGUAGE_NEEDED}.po "\"Content-Type: text/plain; charset=UTF-8\\n\"\n")
14
 
        endif ()
15
 
    endforeach (LANGUAGE_NEEDED ${LANGUAGES_NEEDED})
16
 
    # generate .mo from .po
17
6
    file (GLOB PO_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.po)
18
7
    foreach (PO_INPUT ${PO_FILES})
19
8
        get_filename_component (PO_INPUT_BASE ${PO_INPUT} NAME_WE)
26
15
    endforeach (PO_INPUT ${PO_FILES})
27
16
endmacro(add_translations_directory)
28
17
 
 
18
 
29
19
macro(add_translations_catalog NLS_PACKAGE)
30
20
    add_custom_target (pot COMMENT “Building translation catalog.”)
31
21
    find_program (XGETTEXT_EXECUTABLE xgettext)
37
27
    foreach(FILES_INPUT ${ARGN})
38
28
        set(BASE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${FILES_INPUT})
39
29
 
40
 
        file (GLOB_RECURSE SOURCE_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/ ${BASE_DIRECTORY}/*.c)
 
30
        file (GLOB_RECURSE SOURCE_FILES ${BASE_DIRECTORY}/*.c)
41
31
        foreach(C_FILE ${SOURCE_FILES})
42
32
            set(C_SOURCE ${C_SOURCE} ${C_FILE})
43
33
        endforeach()
44
34
 
45
 
        file (GLOB_RECURSE SOURCE_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/ ${BASE_DIRECTORY}/*.vala)
 
35
        file (GLOB_RECURSE SOURCE_FILES ${BASE_DIRECTORY}/*.vala)
46
36
        foreach(VALA_C_FILE ${SOURCE_FILES})
47
37
            set(VALA_SOURCE ${VALA_SOURCE} ${VALA_C_FILE})
48
38
        endforeach()
49
39
 
50
 
        file (GLOB_RECURSE SOURCE_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/ ${BASE_DIRECTORY}/*.ui)
 
40
        file (GLOB_RECURSE SOURCE_FILES ${BASE_DIRECTORY}/*.ui)
51
41
        foreach(GLADE_C_FILE ${SOURCE_FILES})
52
42
            set(GLADE_SOURCE ${GLADE_SOURCE} ${GLADE_C_FILE})
53
43
        endforeach()
56
46
    set(BASE_XGETTEXT_COMMAND
57
47
        ${XGETTEXT_EXECUTABLE} -d ${NLS_PACKAGE}
58
48
        -o ${CMAKE_CURRENT_SOURCE_DIR}/${NLS_PACKAGE}.pot
59
 
        --add-comments="/" --keyword="_" --keyword="N_" --keyword="C_:1c,2" --keyword="NC_:1c,2" --keyword="ngettext:1,2" --keyword="Q_:1g" --from-code=UTF-8)
 
49
        --keyword="_" --keyword="N_" --from-code=UTF-8)
60
50
 
61
51
   set(CONTINUE_FLAG "")
62
52
 
63
53
    IF(NOT "${C_SOURCE}" STREQUAL "")
64
 
        add_custom_command(TARGET pot WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND ${BASE_XGETTEXT_COMMAND} ${C_SOURCE})
 
54
        add_custom_command(TARGET pot COMMAND ${BASE_XGETTEXT_COMMAND} ${C_SOURCE})
65
55
        set(CONTINUE_FLAG "-j")
66
56
    ENDIF()
67
57
 
68
58
    IF(NOT "${VALA_SOURCE}" STREQUAL "")
69
 
        add_custom_command(TARGET pot WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND ${BASE_XGETTEXT_COMMAND} ${CONTINUE_FLAG} -LC\# ${VALA_SOURCE})
 
59
        add_custom_command(TARGET pot COMMAND ${BASE_XGETTEXT_COMMAND} ${CONTINUE_FLAG} -LC\# ${VALA_SOURCE})
70
60
        set(CONTINUE_FLAG "-j")
71
61
    ENDIF()
72
62
 
73
63
    IF(NOT "${GLADE_SOURCE}" STREQUAL "")
74
 
        add_custom_command (TARGET pot WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND ${BASE_XGETTEXT_COMMAND} ${CONTINUE_FLAG} -LGlade ${GLADE_SOURCE})
 
64
        add_custom_command (TARGET pot COMMAND ${BASE_XGETTEXT_COMMAND} ${CONTINUE_FLAG} -LGlade ${GLADE_SOURCE})
75
65
    ENDIF()  
76
 
endmacro()
 
 
b'\\ No newline at end of file'
 
66
endmacro()