avm99963 | 9f77d0d | 2020-12-28 22:16:12 +0100 | [diff] [blame] | 1 | #!/bin/bash |
Adrià Vilanova MartÃnez | 73c01d4 | 2021-06-08 13:57:36 +0200 | [diff] [blame] | 2 | # |
| 3 | # Downloads updated translations from Crowdin and creates a new commit with the |
| 4 | # new updates. |
| 5 | # |
| 6 | # This commit should be uploaded afterwards for review with the |git review| |
| 7 | # command (take a look to check everything went well before uploading it). |
| 8 | |
avm99963 | 9f77d0d | 2020-12-28 22:16:12 +0100 | [diff] [blame] | 9 | emptyTranslationFile="{}" |
| 10 | |
| 11 | # Download new translations |
| 12 | if [ ! -f "crowdin.yml" ]; then |
| 13 | echo "Copy crowdin.template.yml to crowdin.yml and fill in the API token." |
| 14 | fi |
| 15 | |
| 16 | crowdin download -c crowdin.yml |
| 17 | |
| 18 | cd ../../src/_locales |
| 19 | |
avm99963 | ac2dc4a | 2021-01-10 20:01:35 +0100 | [diff] [blame] | 20 | # Delete empty translations |
avm99963 | 9f77d0d | 2020-12-28 22:16:12 +0100 | [diff] [blame] | 21 | for lang in *; do |
avm99963 | ac2dc4a | 2021-01-10 20:01:35 +0100 | [diff] [blame] | 22 | if [[ "$lang" == "README.md" ]]; then |
| 23 | continue |
| 24 | fi |
avm99963 | 9f77d0d | 2020-12-28 22:16:12 +0100 | [diff] [blame] | 25 | if [ "x$emptyTranslationFile" = "x$(cat $lang/messages.json)" ]; then |
| 26 | echo "$lang has an empty translation. Deleting folder..." |
| 27 | rm -rf $lang |
avm99963 | ac2dc4a | 2021-01-10 20:01:35 +0100 | [diff] [blame] | 28 | else |
| 29 | git add $lang/messages.json |
avm99963 | 9f77d0d | 2020-12-28 22:16:12 +0100 | [diff] [blame] | 30 | fi |
| 31 | done |
avm99963 | ac2dc4a | 2021-01-10 20:01:35 +0100 | [diff] [blame] | 32 | |
| 33 | # Commit new translations |
| 34 | git commit -m "Updating i18n files from Crowdin" |