2
0

i18n-add-language.sh 863 B

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