OSDN Git Service

luci-app-turboacc: fix typo
[immortalwrt/luci.git] / build / i18n-add-language.sh
1 #!/usr/bin/env bash
2
3 LANG=$1
4
5 case "$LANG" in
6         [a-z][a-z]|[a-z][a-z][_-][A-Za-z][A-Za-z]*) : ;;
7         *)
8                 echo "Usage: $0 <ISO_CODE>\n" >&2
9                 exit 1
10         ;;
11 esac
12
13 ADDED=0
14
15 for podir in ./*/*/po; do
16         [ -d "$podir/templates" ] || continue
17
18         mkdir "$podir/$LANG"
19         for catalog in $(cd "$podir/templates"; echo *.pot); do
20                 if [ -f "$podir/templates/$catalog" -a ! -f "$podir/$LANG/${catalog%.pot}.po" ]; then
21                         msginit --no-translator -l "$LANG" -i "$podir/templates/$catalog" -o "$podir/$LANG/${catalog%.pot}.po"
22                         git add "$podir/$LANG/${catalog%.pot}.po"
23                         ADDED=$((ADDED + 1))
24                 fi
25         done
26 done
27
28 if [ $ADDED -gt 0 ]; then
29         echo ""
30         echo "Added $ADDED new translation catalogs for language '$LANG'."
31         echo "Please also edit 'luci.mk' and add"
32         echo ""
33         echo "  LUCI_LANG.$LANG=Native Language Name"
34         echo ""
35         echo "to properly package the translation files."
36         echo ""
37 fi