From dc938565c38e151ac017a08e083e7d0b6a6e0835 Mon Sep 17 00:00:00 2001
From: Julian Rother <julianr@fsmpi.rwth-aachen.de>
Date: Fri, 30 Jul 2021 19:50:58 +0200
Subject: [PATCH] Added update_translations.sh and CI job that outputs coverage

---
 .gitlab-ci.yml         |  5 +++++
 update_translations.sh | 13 +++++++++++++
 2 files changed, 18 insertions(+)
 create mode 100755 update_translations.sh

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index e7476c4f..da0d4211 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -65,3 +65,8 @@ html5validator:
     paths:
     - pages
     - html5validator.log
+
+trans_de:
+  stage: test
+  script:
+  - ./update_translations.sh de
diff --git a/update_translations.sh b/update_translations.sh
new file mode 100755
index 00000000..c3a80dee
--- /dev/null
+++ b/update_translations.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+set -e
+
+pybabel extract -F uffd/babel.cfg -k lazy_gettext -o messages.pot uffd
+pybabel update -i messages.pot -d uffd/translations
+pybabel compile -d uffd/translations
+
+if [ -n "$1" ]; then
+	NUM_EMPTY="$(tr '\n' '|' < uffd/translations/$1/LC_MESSAGES/messages.po | sed 's/msgstr ""|/empty/g' | tr '|' '\n' | grep '^empty$' | wc -l)"
+	NUM_TOTAL="$(grep '^msgid' uffd/translations/$1/LC_MESSAGES/messages.po | wc -l)"
+	# Emulate python-coverage output
+	echo "TOTAL $NUM_TOTAL $(( $NUM_TOTAL - $NUM_EMPTY )) $(( 100 * ($NUM_TOTAL - $NUM_EMPTY) / $NUM_TOTAL ))%"
+fi
-- 
GitLab