summaryrefslogtreecommitdiffstats
path: root/.gitlab-ci/check-potfiles.sh
blob: 0969da180be9cfbd6c3f6fd5e06fc3588486f9d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env bash

srcdirs="src subprojects/extensions-tool"
uidirs="js subprojects/extensions-app"
desktopdirs="data subprojects/extensions-app/ subprojects/extensions-tool"

# find source files that contain gettext keywords
files=$(grep -lR --include='*.c' '\(gettext\|[^I_)]_\)(' $srcdirs)

# find ui files that contain translatable string
files="$files "$(grep -lRi --include='*.ui' 'translatable="[ty1]' $uidirs)

# find .desktop files
files="$files "$(find $desktopdirs -name '*.desktop*')

# 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

# find those that aren't listed in POTFILES.in
missing=$(for f in $files; do ! grep -q ^$f po/POTFILES.in && echo $f; done)

if [ ${#missing} -eq 0 ]; then
  exit 0
fi

cat >&2 <<EOT

The following files are missing from po/POTFILES.po:

EOT
for f in $missing; do
  echo "  $f" >&2
done
echo >&2

exit 1