download_translations 1.42 KB
Newer Older
Xavier Guimard's avatar
Xavier Guimard committed
1 2 3 4 5 6 7 8 9 10
#!/bin/bash

if [ -e ~/.transifex.key ]; then
	for mod in portal manager; do
		echo "#"
		echo "# $mod"
		echo "#"
		for lang in `ls lemonldap-ng-$mod/site/htdocs/static/languages/|perl -ne 's/\.json//;print unless/^(en|fr)/'`; do
			echo
			echo "  # $lang.json"
11
			remote=`echo $lang | perl -pe 's/^zh$/zh_CN/'`
Xavier Guimard's avatar
Xavier Guimard committed
12 13 14
			curl -L --user api:`cat ~/.transifex.key` \
				-X GET \
				-o lemonldap-ng-$mod/site/htdocs/static/languages/$lang.json \
15
				https://www.transifex.com/api/2/project/lemonldapng/resource/${mod}json/translation/$remote/?file
Xavier Guimard's avatar
Xavier Guimard committed
16 17 18 19 20 21 22 23 24 25 26 27
			js_beautify -s=1 -w lemonldap-ng-$mod/site/htdocs/static/languages/$lang.json
			perl -i -pe 's/^ //;s/": "/":"/' lemonldap-ng-$mod/site/htdocs/static/languages/$lang.json
		done
		echo
	done
	echo "#"
	echo "# mail"
	echo "#"
	for lang in `ls lemonldap-ng-portal/site/templates/common/mail/|perl -ne 's/\.json//;print unless/^(en|fr)/'`; do
		echo
		echo "#"
		echo "  # $lang.json"
28
		remote=`echo $lang | perl -pe 's/^zh$/zh_CN/'`
Xavier Guimard's avatar
Xavier Guimard committed
29 30 31
		curl -L --user api:`cat ~/.transifex.key` \
			-X GET \
			-o lemonldap-ng-portal/site/templates/common/mail/$lang.json \
32
			https://www.transifex.com/api/2/project/lemonldapng/resource/mailjson_1/translation/$remote/?file
Xavier Guimard's avatar
Xavier Guimard committed
33 34 35 36 37 38 39
		js_beautify -s=1 -w lemonldap-ng-portal/site/templates/common/mail/$lang.json
		perl -i -pe 's/^ //;s/": "/":"/' lemonldap-ng-portal/site/templates/common/mail/$lang.json
	done
else
	echo "No ~/.transifex.key file found, exiting" >&2
	exit 1
fi