aboutsummaryrefslogtreecommitdiffstats
path: root/crowdin/globals
diff options
context:
space:
mode:
authorkoem <koem@petoria.de>2013-07-25 08:50:14 +0200
committerkoem <koem@petoria.de>2013-07-29 16:41:18 +0200
commitc4529fea894a3f2dc28c3d13f4cbfcd7e6466bf4 (patch)
treeab4114e60d62229e9edc8f419ad1474579451e12 /crowdin/globals
parentbc584a347dc1057f0c2a151196a021463b48ab74 (diff)
downloadcgeo-c4529fea894a3f2dc28c3d13f4cbfcd7e6466bf4.zip
cgeo-c4529fea894a3f2dc28c3d13f4cbfcd7e6466bf4.tar.gz
cgeo-c4529fea894a3f2dc28c3d13f4cbfcd7e6466bf4.tar.bz2
Scripts for crowdin integration
Diffstat (limited to 'crowdin/globals')
-rwxr-xr-xcrowdin/globals44
1 files changed, 44 insertions, 0 deletions
diff --git a/crowdin/globals b/crowdin/globals
new file mode 100755
index 0000000..0efd147
--- /dev/null
+++ b/crowdin/globals
@@ -0,0 +1,44 @@
+#!/bin/bash
+
+. "`dirname $0`/credentials"
+
+OUT=/tmp/crowdin.`basename $0`.`date +%Y-%m-%d.%H:%M:%S`.out
+
+crowdin_surf () {
+ _do curl -o "${OUT}" $@ || die "curl produced an error."
+ grep -q "error" "${OUT}" && (cat "${OUT}" ; die "crowdin access failed." ; )
+ debug "crowdin answer"
+ cat "${OUT}"
+}
+
+require_tools () {
+ # code taken from backup2l
+ local NOT_AVAIL=""
+ for TOOL in $@; do
+ if [ "`which $TOOL 2> /dev/null`" == "" ]; then NOT_AVAIL="$NOT_AVAIL $TOOL"; fi
+ done
+ if [[ "$NOT_AVAIL" != "" ]]; then
+ die "The following required tool(s) cannot be found: $NOT_AVAIL"
+ fi
+}
+
+map_to_crowdin_code () {
+ CODE=$1
+ [[ "$CODE" == "es" ]] && CODE="es-ES"
+ [[ "$CODE" == "sv" ]] && CODE="sv-SE"
+ [[ "$CODE" == "pt" ]] && CODE="pt-PT"
+ echo "$CODE"
+}
+
+finish () { : ; }
+die () { for i; do debug "$i"; done; finish; exit 1; }
+debug () { echo "`date +%Y-%m-%d.%H:%M:%S` `basename $0`: $@"; }
+
+# use this function for executing commands.
+_do () { debug "$@"; eval "$@"; }
+
+require_tools git curl wget unzip
+
+git rev-parse --show-toplevel >& /dev/null || die "Please start this script from within a repo. Aborting."
+cd "`git rev-parse --show-toplevel`"
+