aboutsummaryrefslogtreecommitdiff
path: root/cmake/Translations.cmake
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2013-03-23 16:25:21 -0500
committerCharles Kerr <charles.kerr@canonical.com>2013-03-23 16:25:21 -0500
commit78e8c39d7fb8cb50b7a3cf3cca088f2b5e433166 (patch)
treefdff26faf161227f20e69f672803a772b21ffef9 /cmake/Translations.cmake
parentca4b40ade7f432d98c21ac499a0de63244b1c3cc (diff)
downloadayatana-indicator-session-78e8c39d7fb8cb50b7a3cf3cca088f2b5e433166.tar.gz
ayatana-indicator-session-78e8c39d7fb8cb50b7a3cf3cca088f2b5e433166.tar.bz2
ayatana-indicator-session-78e8c39d7fb8cb50b7a3cf3cca088f2b5e433166.zip
Add Translations.cmake for i18n files
Diffstat (limited to 'cmake/Translations.cmake')
-rw-r--r--cmake/Translations.cmake41
1 files changed, 41 insertions, 0 deletions
diff --git a/cmake/Translations.cmake b/cmake/Translations.cmake
new file mode 100644
index 0000000..476fb37
--- /dev/null
+++ b/cmake/Translations.cmake
@@ -0,0 +1,41 @@
+# Translations.cmake, CMake macros written for Marlin, feel free to re-use them
+
+macro(add_translations_directory NLS_PACKAGE)
+ add_custom_target (i18n ALL COMMENT “Building i18n messages.”)
+ find_program (MSGFMT_EXECUTABLE msgfmt)
+ file (GLOB PO_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.po)
+ foreach (PO_INPUT ${PO_FILES})
+ get_filename_component (PO_INPUT_BASE ${PO_INPUT} NAME_WE)
+ set (MO_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${PO_INPUT_BASE}.mo)
+ add_custom_command (TARGET i18n COMMAND ${MSGFMT_EXECUTABLE} -o ${MO_OUTPUT} ${PO_INPUT})
+
+ install (FILES ${MO_OUTPUT} DESTINATION
+ share/locale/${PO_INPUT_BASE}/LC_MESSAGES
+ RENAME ${NLS_PACKAGE}.mo)
+ endforeach (PO_INPUT ${PO_FILES})
+endmacro(add_translations_directory)
+
+
+macro(add_translations_catalog NLS_PACKAGE)
+ add_custom_target (pot COMMENT “Building translation catalog.”)
+ find_program (XGETTEXT_EXECUTABLE xgettext)
+
+
+ set(C_SOURCE "")
+
+ foreach(FILES_INPUT ${ARGN})
+ file (GLOB_RECURSE SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/${FILES_INPUT}/*.c)
+ foreach(C_FILE ${SOURCE_FILES})
+ set(C_SOURCE ${C_SOURCE} ${C_FILE})
+ endforeach()
+ file (GLOB_RECURSE SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/${FILES_INPUT}/*.vala)
+ foreach(C_FILE ${SOURCE_FILES})
+ set(C_SOURCE ${C_SOURCE} ${C_FILE})
+ endforeach()
+ endforeach()
+
+ add_custom_command (TARGET pot COMMAND
+ ${XGETTEXT_EXECUTABLE} -d ${NLS_PACKAGE} -o ${CMAKE_CURRENT_SOURCE_DIR}/${NLS_PACKAGE}.pot
+ ${VALA_SOURCE} ${C_SOURCE} --keyword="_" --keyword="N_" --from-code=UTF-8
+ )
+endmacro()