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