This repository was archived by the owner on Sep 2, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtxpull
More file actions
executable file
·65 lines (52 loc) · 1.78 KB
/
txpull
File metadata and controls
executable file
·65 lines (52 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/sh
set -e
if [ -z "$1" ]; then
echo "Usage: ./txpull <po file path> [<options or arguments for tx pull>]"
exit 1
fi
if [ -f "$1" ]; then
file=$1
elif [ -n "$(cat .tx/config | grep "\[python-36-tw\.$1\]")" ]; then
file=$(cat .tx/config | grep -A 3 "\[python-36-tw\.$1]" | grep "trans.zh_TW = " | sed 's/trans\.zh_TW = //')
else
echo "Cannot find file or resource $1"
exit 1
fi
resource_slug=$(cat .tx/config | grep -B 3 $file | grep "python-36-tw" | head -n 1 | sed 's/\[\(.*\)\]/\1/')
shift
if [ -z "$resource_slug" ]; then
echo "Cannot find resource slug of $file"
exit 1
fi
if [ -z "$(which tx)" ]; then
echo "Dependency transifex-client not installed, install with the following command:"
echo "$ pip3 install transifex-client"
exit 1
fi
if [ -z "$(which poindent)" ]; then
echo "Dependency poindent not installed, install with the following command:"
echo "$ pip3 install poindent"
exit 1
fi
if [ -z "$(which gettext)" ]; then
echo "Dependency gettext not installed, please install with your package manager."
exit 1
fi
if [ -z "$(which tac)" ]; then
echo "Dependency tac not found, please install with your package manager."
if [ "$(uname -s)" == "Darwin" ]; then
echo "https://unix.stackexchange.com/questions/114041/how-can-i-get-the-tac-command-on-os-x/114042 may be useful for Mac users."
fi
exit 1
fi
echo "Pulling translations of $file from Transifex...\n"
echo "$ tx pull $@ -r $resource_slug"
tx pull $@ -r $resource_slug
echo "\nFixing format consistency in $file...\n"
echo "$ poindent $file"
poindent $file
echo "$ sed -i.bak 's/\"Language: zh-Hant\\\\n\"/\"Language: zh_TW\\\\n\"/' $file"
sed -i.bak 's/"Language: zh-Hant\\n"/"Language: zh_TW\\n"/' "$file"
echo "$ rm $file.bak"
rm "$file".bak
echo "Done."