From c576968e659d5b1bd6961dd0c15a4a40357a9026 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Sun, 30 Jun 2024 13:46:14 +0200 Subject: [PATCH] Added tools script for updating the translation strings and for compiling the message catalog files --- tools/update_translation_strings.sh | 41 +++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100755 tools/update_translation_strings.sh diff --git a/tools/update_translation_strings.sh b/tools/update_translation_strings.sh new file mode 100755 index 000000000..11b47b6bf --- /dev/null +++ b/tools/update_translation_strings.sh @@ -0,0 +1,41 @@ +#!/usr/bin/bash +# SPDX-License-Identifier: MIT +# +# ES-DE Frontend +# update_translation_strings.sh +# +# Extracts translation strings from all C++ files, generates the es-de.pot PO template file +# and merges any changes with the per-language PO files. +# +# To add a new language append it to locale/languages and run msginit, for example: +# msginit -i es-de.pot --locale=sv_SE -o po/sv_SE.po +# +# This script is only intended to be used on Linux systems. +# + +if [ ! -f ../es-app/CMakeLists.txt ]; then + echo "You need to run this script from within the tools directory." + exit +fi + +if [ ! $(which xgettext 2>/dev/null) ]; then + echo "Can't find xgettext which is required to run this script" + exit +fi + +find ../es-app/src/ ../es-core/src -name '*.cpp' -o -name '*.h' | xgettext -f - -o ../locale/es-de.pot -k_ \ +--copyright-holder="Northwestern Software AB" --package-name="ES-DE Frontend" --msgid-bugs-address "info@es-de.org" + +sed -i "1s/.*/# ES-DE Frontend translation strings./" ../locale/es-de.pot +sed -i "2s/.*/# Copyright (c) 2024-present Northwestern Software AB/" ../locale/es-de.pot +sed -i "4s/.*/# Northwestern Software , 2024./" ../locale/es-de.pot +sed -i "s/Language-Team: LANGUAGE /Language-Team: LANGUAGE /" ../locale/es-de.pot + +for language in $(cat ../locale/languages); do + echo Merging strings for locale $language + msgmerge ../locale/po/${language}.po ../locale/es-de.pot -o ../locale/po/${language}.po + echo Compiling message catalog for locale $language + mkdir -p ../resources/locale/${language}/LC_MESSAGES + msgfmt -o ../resources/locale/${language}/LC_MESSAGES/${language}.mo ../locale/po/${language}.po + echo +done