summaryrefslogtreecommitdiffhomepage
path: root/build
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2019-01-10 10:31:05 +0100
committerJo-Philipp Wich <jo@mein.io>2019-01-10 10:37:52 +0100
commite6604d7d84237ea2d30feb10dab757a4fbfa54c5 (patch)
treeba0b89a6ffaea1c300d0a89b806d330c887a79d2 /build
parente5932a52df0ccdfcaadf20cefba3caabf418b68e (diff)
build: add i18n-add-language.sh helper
This script helps to initialize a new translation language over the entire source tree. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'build')
-rwxr-xr-xbuild/i18n-add-language.sh37
1 files changed, 37 insertions, 0 deletions
diff --git a/build/i18n-add-language.sh b/build/i18n-add-language.sh
new file mode 100755
index 000000000..24203c233
--- /dev/null
+++ b/build/i18n-add-language.sh
@@ -0,0 +1,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