i18n-sync.sh 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #!/bin/sh
  2. print_help() {
  3. echo "Execute as ./build/i18n-sync.sh [-b]" >&2
  4. echo "Or run as: ./build/i18n-sync.sh [-b] [module folder e.g. applications/luci-app-example]" >&2
  5. echo "Options:"
  6. echo " -b: Generate the base .pot file ( invokes ./build/mkbasepot.sh )"
  7. }
  8. [ -d ./build ] || {
  9. print_help
  10. exit 1
  11. }
  12. case $1 in
  13. -h | --help )
  14. print_help
  15. exit 0
  16. ;;
  17. -b )
  18. ./build/mkbasepot.sh
  19. shift
  20. ;;
  21. esac
  22. [ -n "$1" ] && set -- "${1%/}"
  23. [ -n "$1" ] || ./build/mkbasepot.sh
  24. # Absent a [folder] parameter, use the current path
  25. find "${1:-.}" -name '*.pot' -and -not -name base.pot | sort | \
  26. xargs -P 10 -I{} sh -c '
  27. dir="${1%/po/templates/*}"
  28. echo "Updating ${1#./} ... "
  29. ./build/i18n-scan.pl "$dir" > "$1"
  30. echo "done"
  31. ' sh {}
  32. # while read path; do
  33. # dir="${path%/po/templates/*}"
  34. # echo "Updating ${path#./} ... "
  35. # # Scan for strings in a directory and stash them in the .pot file:
  36. # ./build/i18n-scan.pl "$dir" > "$path"
  37. # echo "done"
  38. # done
  39. if [ -n "$1" ]; then
  40. if [ "$(uname)" = "Darwin" ] || [ "$(uname)" = "FreeBSD" ]; then
  41. # macOS-specific commands
  42. find "$1" -path '*/templates/*.pot' -print0 | xargs -0r stat -f '%N' | \
  43. xargs -r -n 1 dirname | \
  44. xargs -r -n 1 dirname | sort | \
  45. xargs -r -n 1 -P 40 ./build/i18n-update.pl
  46. elif [ "$(uname)" = "Linux" ]; then
  47. # Linux-specific commands
  48. find "$1" -path '*/templates/*.pot' -printf '%h ' | \
  49. xargs -r -n 1 dirname | \
  50. xargs -r -n 1 -P 40 ./build/i18n-update.pl
  51. # elif [ "$(uname)" = "SunOS" ]; then
  52. # # Solaris-specific commands
  53. else
  54. # GNU specific commands can go here:
  55. find "$1" -path '*/templates/*.pot' -printf '%h ' | \
  56. xargs -r -n 1 dirname | \
  57. xargs -r -n 1 -P 40 ./build/i18n-update.pl
  58. fi
  59. else
  60. # this performs operations on all .po files
  61. ./build/i18n-update.pl
  62. fi