Last active
December 21, 2015 10:59
-
-
Save AntoineTurmel/6295589 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
bz_user= | |
bz_pass= | |
tx_api_url="http://beta.babelzilla.org/api/2/project/" | |
tx_project="ngaletest" | |
curl -L --user $bz_user:$bz_pass -X GET $tx_api_url$tx_project/resources/ > filelist.json | |
cat filelist.json | grep slug | sed -e 's/"slug": "//g' | sed -e 's/",//g' | sed -e 's/ //g' > filelist | |
wd=`pwd` | |
#cd locales | |
for lang_code in $(cat $wd/all-locales) | |
do | |
for lang_file in $(cat $wd/filelist) | |
do | |
if [ -f $lang_file-$lang_code ]; then | |
curl -L --user $bz_user:$bz_pass -X GET $tx_api_url$tx_project/resource/$lang_file/stats/$lang_code/ > $lang_file-$lang_code.new | |
#result=$(cmp $lang_file-$lang_code.new $lang_file-$lang_code) | |
cmp $lang_file-$lang_code.new $lang_file-$lang_code 1>/dev/null 2>&1; result=$? | |
#if [ -z "$result" ]; then | |
if [ $result -eq 1 ]; then | |
rm $lang_file-$lang_code | |
mv $lang_file-$lang_code.new $lang_file-$lang_code | |
bz_commiter=`cat $lang_file-$lang_code | grep last_commiter | sed -e 's/ "last_commiter": "//g' | sed -e 's/",//g'` | |
bz_mail=`cat translators.json | grep $bz_commiter | sed -e 's/ "'$bz_commiter'": "//g' | sed -e 's/"//g' | sed -e 's/,//g'` | |
if [ "$bz_mail" = "" ]; then | |
bz_mail="[email protected]" | |
fi | |
tx pull -l $lang_code -r $tx_project.$lang_file --mode=skipped | |
git commit -a -m "Locale ($lang_code) update" --author="$bz_commiter <$bz_mail>" | |
fi | |
else | |
curl -L --user $bz_user:$bz_pass -X GET $tx_api_url$tx_project/resource/$lang_file/stats/$lang_code/ > $lang_file-$lang_code | |
fi | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment