navidrome/update-translations.sh

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

32 lines
749 B
Bash
Raw Normal View History

2023-01-27 16:12:53 +01:00
#!/bin/sh
set -e
download_lang() {
filename=resources/i18n/"$1".json
2023-01-27 16:12:53 +01:00
url=$(curl -s -X POST https://poeditor.com/api/ \
-d api_token="${POEDITOR_APIKEY}" \
-d action="export" \
-d id="${POEDITOR_PROJECTID}" \
-d language="$1" \
-d type="key_value_json" | jq -r .item)
if [ -z "$url" ]; then
echo "Failed to export $1"
return 1
fi
curl -sSL "$url" > poeditor.json
if [ "$(jq -c . < $filename)" != "$(jq -c . < poeditor.json)" ]; then
mv poeditor.json "$filename"
else
rm poeditor.json
fi
2023-01-27 16:12:53 +01:00
}
for file in resources/i18n/*.json; do
name=$(basename "$file")
code=$(echo "$name" | cut -f1 -d.)
lang=$(jq -r .languageName < "$file")
echo "Downloading $lang ($code)"
download_lang "$code"
done