aboutsummaryrefslogtreecommitdiff
path: root/cmake/Translations.cmake
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2014-08-20 23:03:20 -0500
committerCharles Kerr <charles.kerr@canonical.com>2014-08-20 23:03:20 -0500
commitde41e383081e645c85976e2c0a72687af01d0165 (patch)
tree97761dc65010b34da85b6bc1e1b90fa8072b52cb /cmake/Translations.cmake
parent81e6d9633da0ac96b919032e51f5ae48f77113db (diff)
downloadayatana-indicator-display-de41e383081e645c85976e2c0a72687af01d0165.tar.gz
ayatana-indicator-display-de41e383081e645c85976e2c0a72687af01d0165.tar.bz2
ayatana-indicator-display-de41e383081e645c85976e2c0a72687af01d0165.zip
add cmake/ directory
Diffstat (limited to 'cmake/Translations.cmake')
-rw-r--r--cmake/Translations.cmake37
1 files changed, 37 insertions, 0 deletions
diff --git a/cmake/Translations.cmake b/cmake/Translations.cmake
new file mode 100644
index 0000000..b51c39d
--- /dev/null
+++ b/cmake/Translations.cmake
@@ -0,0 +1,37 @@
+# Translations.cmake, CMake macros written for Marlin, feel free to re-use them
+
+macro(add_translations_directory NLS_PACKAGE)
+ add_custom_target (i18n ALL)
+ 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
+ ${CMAKE_INSTALL_LOCALEDIR}/${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)
+
+ # init this list, which will hold all the sources across all dirs
+ set(SOURCES "")
+
+ # add each directory's sources to the overall sources list
+ foreach(FILES_INPUT ${ARGN})
+ set (DIR ${CMAKE_CURRENT_SOURCE_DIR}/${FILES_INPUT})
+ file (GLOB_RECURSE DIR_SOURCES ${DIR}/*.c ${DIR}/*.cc ${DIR}/*.cpp ${DIR}/*.cxx ${DIR}/*.vala)
+ set (SOURCES ${SOURCES} ${DIR_SOURCES})
+ endforeach()
+
+ add_custom_command (TARGET pot COMMAND
+ ${XGETTEXT_EXECUTABLE} -d ${NLS_PACKAGE} -o ${CMAKE_CURRENT_SOURCE_DIR}/${NLS_PACKAGE}.pot
+ ${SOURCES} --keyword="_" --keyword="N_" --from-code=UTF-8
+ )
+endmacro()