1
1
#! /bin/sh
2
2
3
- if [ x" $1 " == x ];
4
- then
3
+ if [-z " $1 " ]; then
5
4
echo " Usage: ./txpull <po file path> [<options or arguments for tx pull>]"
6
5
exit 1
7
6
fi
8
7
9
- if [! -f " $1 " ];
10
- then
8
+ if [! -f " $1 " ]; then
11
9
echo " File$1 does not exist"
12
10
exit 1
13
11
fi
14
12
15
13
file=" $1 "
16
14
shift
17
15
18
- resource_slug=" $( cat .tx/config| grep -B 1$file | head -n 1| sed' s/\[\(.*\)\]/\1/' ) "
19
- if [ x" $resource_slug " == x ];
20
- then
16
+ resource_slug=" $( cat .tx/config| grep -B 3$file | grep" python-36-tw" | head -n 1| sed' s/\[\(.*\)\]/\1/' ) "
17
+ if [-z " $resource_slug " ]; then
21
18
echo " Resource of file$file not found"
22
19
exit 1
23
20
fi
24
21
22
+ if [-z " $( which tx) " ]; then
23
+ echo " Dependency transifex-client not installed, install with the following command:"
24
+ echo " $ pip3 install transifex-client"
25
+ exit 1
26
+ fi
27
+
28
+ if [-z " $( which poindent) " ]; then
29
+ echo " Dependency poindent not installed, install with the following command:"
30
+ echo " $ pip3 install poindent"
31
+ exit 1
32
+ fi
33
+
34
+ if [-z " $( which gettext) " ]; then
35
+ echo " Dependency gettext not installed, please install with your package manager."
36
+ exit 1
37
+ fi
38
+
39
+ if [-z " $( which tac) " ]; then
40
+ echo " Dependency tac not found, please install with your package manager."
41
+ if [" $( uname -s) " == " Darwin" ]; then
42
+ echo " https://unix.stackexchange.com/questions/114041/how-can-i-get-the-tac-command-on-os-x/114042 may be useful for Mac users."
43
+ fi
44
+ exit 1
45
+ fi
46
+
25
47
echo " Pulling translations of$file from Transifex...\n"
26
48
echo " $ tx pull$@ -r$resource_slug "
27
49
tx pull$@ -r$resource_slug
@@ -30,7 +52,9 @@ echo "\nFixing format consistency in $file...\n"
30
52
echo " $ poindent$file "
31
53
poindent$file
32
54
33
- echo " sed -i '' -e 's/\" Language: zh-Hant\\\\ n\" /\" Language: zh_TW\\\\ n\" /'$file "
34
- sed -i' ' -e' s/"Language: zh-Hant\\n"/"Language: zh_TW\\n"/' $file
55
+ echo " $ sed -i.bak 's/\" Language: zh-Hant\\\\ n\" /\" Language: zh_TW\\\\ n\" /'$file "
56
+ sed -i.bak' s/"Language: zh-Hant\\n"/"Language: zh_TW\\n"/' " $file "
57
+ echo " $ rm$file .bak"
58
+ rm" $file " .bak
35
59
36
60
echo " Done."