11#! /bin/sh
22
3- if [ x" $1 " == x ];
4- then
3+ if [ -z " $1 " ]; then
54 echo " Usage: ./txpull <po file path> [<options or arguments for tx pull>]"
65 exit 1
76fi
87
9- if [ ! -f " $1 " ];
10- then
8+ if [ ! -f " $1 " ]; then
119 echo " File $1 does not exist"
1210 exit 1
1311fi
1412
1513file=" $1 "
1614shift
1715
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
2118 echo " Resource of file $file not found"
2219 exit 1
2320fi
2421
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+
2547echo " Pulling translations of $file from Transifex...\n"
2648echo " $ tx pull $@ -r $resource_slug "
2749tx pull $@ -r $resource_slug
@@ -30,7 +52,9 @@ echo "\nFixing format consistency in $file...\n"
3052echo " $ poindent $file "
3153poindent $file
3254
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
3559
3660echo " Done."
0 commit comments