From 7753e420780ba9db74a0134521d25bbd56ec294c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Fri, 18 Oct 2019 22:51:31 +0200 Subject: [PATCH] Add translation output to Cmake --- CMakeLists.txt | 1 + translations/CMakeLists.txt | 4 ++++ translations/generate-mo.sh | 23 +++++++++++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 translations/CMakeLists.txt create mode 100755 translations/generate-mo.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 9808ba0..7899a2e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,6 +39,7 @@ ENDIF(CMAKE_BUILD_TYPE STREQUAL "Debug") add_subdirectory(resources) add_subdirectory(doxygen) +add_subdirectory(translations) add_subdirectory(version) include_directories(${GLIB_INCLUDE_DIRS} ${GTK3_INCLUDE_DIRS} ${CAIRO_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/include) diff --git a/translations/CMakeLists.txt b/translations/CMakeLists.txt new file mode 100644 index 0000000..3d85c59 --- /dev/null +++ b/translations/CMakeLists.txt @@ -0,0 +1,4 @@ +add_custom_target(translations + COMMAND ./generate-mo.sh "${PROJECT_BINARY_DIR}/translations" + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMENT "Generating translation locales") diff --git a/translations/generate-mo.sh b/translations/generate-mo.sh new file mode 100755 index 0000000..872e94c --- /dev/null +++ b/translations/generate-mo.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +SOURCE="${BASH_SOURCE[0]}" +while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink + DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null && pwd )" + SOURCE="$(readlink "$SOURCE")" + [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located +done +DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null && pwd )" +cd "$DIR" + +if [ -z $1 ]; then + echo "Must supply an output name" + exit -2 +fi + +for langdir in `find ./pot/po -mindepth 1 -maxdepth 1 -type d`; do + lang=`basename "$langdir"` + dest="$1/locale/$lang/LC_MESSAGES" + mkdir -p "$dest" + pofiles=`find "$langdir" -name "*.po"` + msgfmt --output-file="$dest/gds-render.mo" "$pofiles" +done