summaryrefslogtreecommitdiffhomepage
path: root/build/i18n-add-language.sh
blob: 24203c23317c301bcb58938cd03fac3ef23c8995 (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
#!/usr/bin/env bash

LANG=$1

case "$LANG" in
	[a-z][a-z]|[a-z][a-z]-[a-z][a-z]) : ;;
	*)
		echo "Usage: $0 <ISO_CODE>\n" >&2
		exit 1
	;;
esac

ADDED=0

for podir in ./*/*/po; do
	[ -d "$podir/templates" ] || continue

	mkdir "$podir/$LANG"
	for catalog in $(cd "$podir/templates"; echo *.pot); do
		if [ -f "$podir/templates/$catalog" -a ! -f "$podir/$LANG/${catalog%.pot}.po" ]; then
			msginit --no-translator -l "$LANG" -i "$podir/templates/$catalog" -o "$podir/$LANG/${catalog%.pot}.po"
			git add "$podir/$LANG/${catalog%.pot}.po"
			ADDED=$((ADDED + 1))
		fi
	done
done

if [ $ADDED -gt 0 ]; then
	echo ""
	echo "Added $ADDED new translation catalogs for language '$LANG'."
	echo "Please also edit 'luci.mk' and add"
	echo ""
	echo "  LUCI_LANG.$LANG=Native Language Name"
	echo ""
	echo "to properly package the translation files."
	echo ""
fi