File: check_lang_enabled.sh

package info (click to toggle)
postgis 3.5.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 70,052 kB
  • sloc: ansic: 162,204; sql: 93,950; xml: 53,121; cpp: 12,646; perl: 5,658; sh: 5,369; makefile: 3,434; python: 1,205; yacc: 447; lex: 151; pascal: 58
file content (76 lines) | stat: -rwxr-xr-x 1,713 bytes parent folder | download | duplicates (3)
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/sh

usage() {
  echo "Usage: $0 [<sourcedir>]"
}

### COMMAND LINE PARSING
RD= # Root source dir
while [ $# -gt 0 ]; do
  if [ "$1" = "--help" ]; then
    usage
    exit 0
  elif [ -z "${RD}" ]; then
    RD=$1
  else
    echo "ERROR: unrecognized extra argument $1" >&2
    usage >&2
    exit 1
  fi
  shift
done

if [ -z "${RD}" ]; then
  RD=$(cd $(dirname $0)/..; pwd)
fi
test -d ${RD}/doc/po || {
  echo "ERROR: Source dir ${RD} does not contain a doc/po directory" >&2
  exit 1
}

ENABLED_TRANSLATIONS=$(grep ^translations ${RD}/doc/Makefile.in | cut -d= -f2)
fail=0

CORRECTLY_ENABLED=
CHECK_WOODIE=no

if test -d ${RD}/.woodpecker; then
  CHECK_WOODIE=yes
else
  echo "SKIP: woodpecker config not checked as ${RD}/.woodpecker dir is not present"
fi

# Available languages are those for which we have at least a .po file
for LANG in $(
  find ${RD}/doc/po/ -name '*.po' | xargs dirname | sort -u | xargs -n 1 basename
)
do

  # Check that the language dir has a Makefile.in
  test -f ${RD}/doc/po/${LANG}/Makefile.in || {
    echo "FAIL: ${RD}/doc/po/${LANG} is missing a Makefile.in"
    fail=$((fail+1))
    continue
  }

  # Check that the language dir is enabled in doc/Makefile.in
  echo "${ENABLED_TRANSLATIONS}" | grep -qw "${LANG}" || {
    echo "FAIL: ${LANG} is not enabled in ${RD}/doc/Makefile.in (translations)"
    fail=$((fail+1))
    continue
  }

  # Check that the language check is enabled for woodie
  if test "${CHECK_WOODIE}" = "yes"; then
    grep -qw "${LANG}" ${RD}/.woodpecker/docs.yml || {
      echo "FAIL: ${LANG} is not enabled in ${RD}/.woodpecker/docs.yml"
      fail=$((fail+1))
      continue
    }
  fi

  echo "PASS: ${LANG} is correctly enabled"

done

exit $fail