1
# Translations.cmake, CMake macros written for Marlin, feel free to re-use them
3
macro(add_translations_directory NLS_PACKAGE)
4
add_custom_target (i18n ALL COMMENT “Building i18n messages.”)
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")
15
endforeach (LANGUAGE_NEEDED ${LANGUAGES_NEEDED})
16
# generate .mo from .po
17
file (GLOB PO_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.po)
18
foreach (PO_INPUT ${PO_FILES})
19
get_filename_component (PO_INPUT_BASE ${PO_INPUT} NAME_WE)
20
set (MO_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${PO_INPUT_BASE}.mo)
21
add_custom_command (TARGET i18n COMMAND ${MSGFMT_EXECUTABLE} -o ${MO_OUTPUT} ${PO_INPUT})
23
install (FILES ${MO_OUTPUT} DESTINATION
24
share/locale/${PO_INPUT_BASE}/LC_MESSAGES
25
RENAME ${NLS_PACKAGE}.mo)
26
endforeach (PO_INPUT ${PO_FILES})
27
endmacro(add_translations_directory)
29
macro(add_translations_catalog NLS_PACKAGE)
30
add_custom_target (pot COMMENT “Building translation catalog.”)
31
find_program (XGETTEXT_EXECUTABLE xgettext)
37
foreach(FILES_INPUT ${ARGN})
38
set(BASE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${FILES_INPUT})
40
file (GLOB_RECURSE SOURCE_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/ ${BASE_DIRECTORY}/*.c)
41
foreach(C_FILE ${SOURCE_FILES})
42
set(C_SOURCE ${C_SOURCE} ${C_FILE})
45
file (GLOB_RECURSE SOURCE_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/ ${BASE_DIRECTORY}/*.vala)
46
foreach(VALA_C_FILE ${SOURCE_FILES})
47
set(VALA_SOURCE ${VALA_SOURCE} ${VALA_C_FILE})
50
file (GLOB_RECURSE SOURCE_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/ ${BASE_DIRECTORY}/*.ui)
51
foreach(GLADE_C_FILE ${SOURCE_FILES})
52
set(GLADE_SOURCE ${GLADE_SOURCE} ${GLADE_C_FILE})
56
set(BASE_XGETTEXT_COMMAND
57
${XGETTEXT_EXECUTABLE} -d ${NLS_PACKAGE}
58
-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)
63
IF(NOT "${C_SOURCE}" STREQUAL "")
64
add_custom_command(TARGET pot WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND ${BASE_XGETTEXT_COMMAND} ${C_SOURCE})
65
set(CONTINUE_FLAG "-j")
68
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})
70
set(CONTINUE_FLAG "-j")
73
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})
b'\\ No newline at end of file'