blob: 0efd14722093b2588495724b64ac54e3c490bf69 (
plain)
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
35
36
37
38
39
40
41
42
43
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`"
|