forked from isso-comments/isso
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtx-push
executable file
·34 lines (26 loc) · 887 Bytes
/
tx-push
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
#!/usr/bin/env fish
set TRANSIFEX "https://www.transifex.com/api/2"
if [ (count $argv) -ne 1 ]
echo "tx-push FILE"
exit 2
end
if [ ! -f ~/.transifexrc ]
echo "no ~/.transifexrc found"
exit 1
end
set user (cat ~/.transifexrc | grep -E "^username" | awk -F " ?= ?" '{ print $2 }')
set pass (cat ~/.transifexrc | grep -E "^password" | awk -F " ?= ?" '{ print $2 }')
set lang (echo $argv | cut -d / -f 5 | cut -d . -f 1)
set trans (mktemp -t tx.XXX)
if [ $lang = "en" ]
set url "$TRANSIFEX/project/isso/resource/js/content/"
else
set url "$TRANSIFEX/project/isso/resource/js/translation/$lang/"
end
printf '{"content":' > $trans
cat $argv \
| sed "s,^define(,,g;\$ s,);,,g" \
| python -c 'import json,sys; print json.dumps(sys.stdin.read())' \
>> $trans
printf '}' >> $trans
curl -L -u $user:$pass -XPUT $url -H "Content-Type: application/json" -d @$trans