add tx-pull and tx-push FILE helper scripts
tx-pull fetches translations from Transifex to .tx/<ressource>/<lang> and converts the JSON into an AMD module. Requires `transifex-client` from PyPi. tx-push FILE submits a AMD translation module to Transifex using `curl` and credentials from ~/.transifexrc.
This commit is contained in:
parent
9dd066c6a6
commit
055a20606a
13
bin/tx-pull
Executable file
13
bin/tx-pull
Executable file
@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env fish
|
||||
|
||||
set -g TRANSIFEX ".tx/js/"
|
||||
set -g JS "isso/js/app/i18n/%s.js"
|
||||
|
||||
# fetch latest translations to .tx/<ressource>/<lang>
|
||||
tx pull -a
|
||||
|
||||
for lang in (ls $TRANSIFEX)
|
||||
printf "define(" > (printf $JS $lang)
|
||||
cat .tx/js/$lang >> (printf $JS $lang)
|
||||
printf ");\n" >> (printf $JS $lang)
|
||||
end
|
34
bin/tx-push
Executable file
34
bin/tx-push
Executable file
@ -0,0 +1,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)
|
||||
|
||||
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
|
Loading…
Reference in New Issue
Block a user