i18n-init.sh 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/bin/sh
  2. PATTERN=$1
  3. SCM=
  4. echo $(basename "$0") "initialises po/ i18n catalogues in empty language sub-folders."
  5. echo $(basename "$0") "is deprecated and may be removed in the future."
  6. echo "Hint: run i18n-add-language.sh instead."
  7. [ -d .svn ] && SCM="svn"
  8. git=$( command -v git 2>/dev/null )
  9. [ "$git" ] && "$git" status >/dev/null && SCM="git"
  10. [ -z "$SCM" ] && {
  11. echo "Unsupported SCM tool" >&2
  12. exit 1
  13. }
  14. [ -z "$PATTERN" ] && PATTERN="*.pot"
  15. [ "${1#luci-}" ] && {
  16. # user passed e.g. applications/luci-app-example - build template pot
  17. path="${1%/}"
  18. mkdir -p "$path/po/templates"
  19. ./build/i18n-scan.pl "$1" > "$1"/po/templates/"${path##*-}".pot && echo "Created $1/po/templates/${path##*-}.pot"
  20. slashes="${path//[^\/]}/" # Keep only slashes
  21. depth="${#slashes}" # Get the length of the remaining string (number of slashes)
  22. prefix=$(printf '../%.0s' $(seq 1 "$depth"))
  23. pushd "$path" 2&>/dev/null || exit
  24. "$prefix"build/i18n-add-language.sh
  25. }
  26. for lang in $(cd po; echo ?? ??_??); do
  27. for file in $(cd po/templates; echo $PATTERN); do
  28. if [ -f po/templates/$file -a ! -f "po/$lang/${file%.pot}.po" ]; then
  29. msginit --no-translator -l "$lang" -i "po/templates/$file" -o "po/$lang/${file%.pot}.po"
  30. $SCM add "po/$lang/${file%.pot}.po"
  31. fi
  32. done
  33. done
  34. popd 2&>/dev/null|| exit