|
1 | 1 | #!/bin/bash |
2 | | -if [ ! -e /usr/bin/xgettext ]; then |
| 2 | + |
| 3 | +if [ ! -x /usr/bin/xgettext ]; then |
3 | 4 | echo " **********************************************************" |
4 | 5 | echo " * Unable to find xgettext please install gettext package *" |
5 | 6 | echo " **********************************************************" |
6 | 7 | exit 3 |
7 | 8 | fi |
8 | 9 |
|
9 | | -echo "[ * ] Move hestiacp.pot to Move hestiacp.pot.old" |
| 10 | +echo "[ * ] Move hestiacp.pot to hestiacp.pot.old" |
10 | 11 | mv hestiacp.pot hestiacp.pot.old |
11 | | -echo "" > hestiacp.pot |
| 12 | +true > hestiacp.pot |
12 | 13 |
|
13 | 14 | echo "[ * ] Search *.php *.html and *.sh for php based gettext functions" |
14 | 15 | find ../.. \( -name '*.php' -o -name '*.html' -o -name '*.sh' \) | xgettext --output=hestiacp.pot --language=PHP --join-existing -f - |
15 | | -OLDIFS=$IFS |
16 | | -IFS=$'\n' |
| 16 | + |
17 | 17 | # Scan the description string for list updates page |
18 | | -for string in $(awk -F'DESCR=' '/data=".+ DESCR=[^"]/ {print $2}' ../../bin/v-list-sys-hestia-updates | cut -d\' -f2); do |
19 | | - if [ -z "$(grep "\"$string\"" hestiacp.pot)" ]; then |
20 | | - echo -e "\n#: ../../bin/v-list-sys-hestia-updates:"$(grep -n "$string" ../../bin/v-list-sys-hestia-updates | cut -d: -f1)"\nmsgid \"$string\"\nmsgstr \"\"" >> hestiacp.pot |
| 18 | +while IFS= read -r string; do |
| 19 | + if ! grep -q "\"$string\"" hestiacp.pot; then |
| 20 | + echo -e "\n#: ../../bin/v-list-sys-hestia-updates:$(grep -n "$string" ../../bin/v-list-sys-hestia-updates | cut -d: -f1)\nmsgid \"$string\"\nmsgstr \"\"" >> hestiacp.pot |
21 | 21 | fi |
22 | | -done |
| 22 | +done < <(awk -F'DESCR=' '/data=".+ DESCR=[^"]/ {print $2}' ../../bin/v-list-sys-hestia-updates | cut -d\' -f2) |
| 23 | + |
23 | 24 | # Scan the description string for list server page |
24 | | -for string in $(awk -F'SYSTEM=' '/data=".+ SYSTEM=[^"]/ {print $2}' ../../bin/v-list-sys-services | cut -d\' -f2); do |
25 | | - if [ -z "$(grep "\"$string\"" hestiacp.pot)" ]; then |
26 | | - echo -e "\n#: ../../bin/v-list-sys-services:"$(grep -n "$string" ../../bin/v-list-sys-services | cut -d: -f1)"\nmsgid \"$string\"\nmsgstr \"\"" >> hestiacp.pot |
| 25 | +while IFS= read -r string; do |
| 26 | + if ! grep -q "\"$string\"" hestiacp.pot; then |
| 27 | + echo -e "\n#: ../../bin/v-list-sys-services:$(grep -n "$string" ../../bin/v-list-sys-services | cut -d: -f1)\nmsgid \"$string\"\nmsgstr \"\"" >> hestiacp.pot |
27 | 28 | fi |
28 | | -done |
29 | | -IFS=$OLDIFS |
| 29 | +done < <(awk -F'SYSTEM=' '/data=".+ SYSTEM=[^"]/ {print $2}' ../../bin/v-list-sys-services | cut -d\' -f2) |
30 | 30 |
|
31 | 31 | # Prevent only date change become a commit |
32 | | -if [ $(diff hestiacp.pot hestiacp.pot.old | wc -l) != 2 ]; then |
33 | | - rm hestiacp.pot |
34 | | - mv hestiacp.pot.old hestiacp.pot |
35 | | -else |
| 32 | +if [ "$(diff hestiacp.pot hestiacp.pot.old | wc -l)" -gt 4 ]; then |
36 | 33 | rm hestiacp.pot.old |
| 34 | +else |
| 35 | + mv -f hestiacp.pot.old hestiacp.pot |
37 | 36 | fi |
0 commit comments