forked from WeakAuras/WeakAuras2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwowace_translations.sh
executable file
·41 lines (34 loc) · 1.01 KB
/
wowace_translations.sh
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
#!/bin/bash
declare -A locale_files=(
["WeakAuras"]="WeakAuras_Main.lua"
["WeakAuras/Options"]="WeakAuras_Options.lua"
["WeakAuras/Templates"]="WeakAuras_Templates.lua"
)
tempfile=$( mktemp )
trap 'rm -f $tempfile' EXIT
do_import() {
namespace="$1"
file="$2"
: > "$tempfile"
echo -n "Importing $namespace..."
result=$( curl -sS -X POST -w "%{http_code}" -o "$tempfile" \
-H "X-Api-Token: $CF_API_TOKEN" \
-F "metadata={ language: \"enUS\", namespace: \"$namespace\", \"missing-phrase-handling\": \"DeletePhrase\" }" \
-F "localizations=<$file" \
"https://www.wowace.com/api/projects/65387/localization/import"
) || exit 1
case $result in
200) echo "done." ;;
*)
echo "error! ($result)"
[ -s "$tempfile" ] && grep -q "errorMessage" "$tempfile" && cat "$tempfile" | jq --raw-output '.errorMessage'
exit 1
;;
esac
}
lua babelfish.lua || exit 1
echo
for namespace in "${!locale_files[@]}"; do
do_import "$namespace" "${locale_files[$namespace]}"
done
exit 0