aboutsummaryrefslogtreecommitdiff
path: root/aux/workflow/l10n.sh
blob: 81a7d029c5fa50ee959f251601f4b8f549023b52 (plain) (blame)
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
#!/bin/sh
set -eu

LANGS=
while getopts 'l:' flag; do
	case "$flag" in
		l)
			LANGS="$OPTARG"
			;;
		*)
			exit 2
			;;
	esac
done
shift $((OPTIND - 1))
if [ -z "$LANGS" ]; then
	echo "Missing LANG" >&2
	exit 2
fi

for f in $(find $@ -not -name '*.en.*'); do
	case "$f" in
		*.en.[1-9].in)
			manpage "$f"
			;;
		*)
			echo "Unsupported file format: $f" >&2
			exit 2
			;;
	esac
done

manpage() {
	from_f="$1"
	for l in $LANGS; do
		to_f="$(echo "$from_f" | sed "s/\.en\./.$l./")"
		po4a-updatepo -f man -m "$from_f" -p "po/$l.po"
		OUT="$(po4a-translate -f man -m "$from_f" -p "po/$l.po" -l "$to_f" -k 0 -v 2>&1)"
		echo "$OUT" >&2
		if ! echo "$OUT" | grep -qF ' is 100% translated ('; then
			printf '\n\tWARNING!\n	Missing translations for %s\n\n' "$to_f" >&2
		fi
	done
}