summaryrefslogtreecommitdiff
path: root/.gitlab
diff options
context:
space:
mode:
authorNiels De Graef <nielsdegraef@gmail.com>2022-11-24 02:36:30 +0100
committerNiels De Graef <nielsdegraef@gmail.com>2023-02-10 10:27:51 +0000
commitb344ee9d801a84c92c63054c41b58799292e37ef (patch)
tree8190c5336f2821048c3cac050a5706c8c759d4a2 /.gitlab
parent942a5ce3c8c3814758d672d52b431fbc9ddb878b (diff)
downloadgnome-contacts-b344ee9d801a84c92c63054c41b58799292e37ef.tar.gz
ci: Add a check for potfiles
Use Florian's script in gnome-shell as basis and adapt it to our needs
Diffstat (limited to '.gitlab')
-rwxr-xr-x.gitlab/ci/check-potfiles.sh41
1 files changed, 41 insertions, 0 deletions
diff --git a/.gitlab/ci/check-potfiles.sh b/.gitlab/ci/check-potfiles.sh
new file mode 100755
index 0000000..b14f863
--- /dev/null
+++ b/.gitlab/ci/check-potfiles.sh
@@ -0,0 +1,41 @@
+#!/usr/bin/env bash
+
+srcdirs="src"
+uidirs="data/ui"
+
+# find source files that contain gettext keywords
+vala_files="$(grep -lR --include='*.vala' '\(gettext\|[^I_)]_\)(' $srcdirs)"
+c_files="$(grep -lR --include='*.c' '\(gettext\|[^I_)]_\)(' $srcdirs)"
+
+# find ui files that contain translatable string
+ui_files="$(grep -lRi --include='*.ui' 'translatable="[ty1]' $uidirs)"
+
+files="$vala_files $c_files $ui_files"
+
+# filter out excluded files
+if [ -f po/POTFILES.skip ]; then
+ files="$(for f in $files; do ! grep -q "^$f$" po/POTFILES.skip && echo "$f"; done)"
+fi
+
+# Test 1: find all files that are missing from POTFILES.in
+missing="$(for f in $files; do ! grep -q "^$f$" po/POTFILES.in && echo "$f"; done)"
+if [ ${#missing} -ne 0 ]; then
+ echo >&2 "The following files are missing from po/POTFILES.in:"
+ for f in ${missing[@]}; do
+ echo " $f" >&2
+ done
+ echo >&2
+ exit 1
+fi
+
+# Test 2: find all Vala files that miss a corresponding .c file in POTFILES.skip
+vala_c_files="$(for f in $vala_files; do echo "${f%.vala}.c"; done)"
+vala_c_files_missing="$(for f in ${vala_c_files[@]}; do ! grep -q "^$f$" po/POTFILES.skip && echo "$f"; done)"
+if [ ${#vala_c_files_missing} -ne 0 ]; then
+ echo >&2 "The following files are missing from po/POTFILES.skip:"
+ for f in ${vala_c_files_missing[@]}; do
+ echo " $f" >&2
+ done
+ echo >&2
+ exit 1
+fi