This repository has been archived by the owner on Nov 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
i18n_update.sh
executable file
·44 lines (39 loc) · 1.68 KB
/
i18n_update.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
42
43
44
#!/bin/sh
# Download latest community website translations from Transifex and copy them over the existing local files.
# Transifex username and password
USERNAME=dnaber
PASSWORD=`cat ~/.transifex_password`
rm -I i18n-temp
mkdir i18n-temp
cd i18n-temp
# list of languages in the same order as on https://www.transifex.com/projects/p/languagetool/:
for lang in en ast be br ca zh da nl eo fr gl de el_GR it pl ru sl es tl uk ro sk cs sv is lt km pt_PT pt_BR fa sr
do
SOURCE=downloaded.tmp
curl --user $USERNAME:$PASSWORD https://www.transifex.com/api/2/project/languagetool/resource/community-website/translation/$lang/?file >$SOURCE
#sed -i 's/\\\\/\\/g' $SOURCE
localLang=$lang
if [ $lang = 'pt_PT' ]; then
# special case: if this is named pt_PT it never becomes active because we use "lang=xx" links
# in the web app that don't contain the country code:
localLang=pt
fi
TARGET="../grails-app/i18n/messages_${localLang}.properties"
# ignore new strings not translated yet (Transifex adds them, but commented out):
modified_lines=`diff $TARGET $SOURCE | grep "^[<>]" | grep "^[<>] [a-zA-Z]"|wc -l`
if [ $modified_lines -ne "0" ]; then
echo "Moving $SOURCE to $TARGET ($modified_lines lines modified)"
mv $SOURCE $TARGET
else
echo "No real modification in $lang"
rm $SOURCE
fi
done
# messages.properties is used as the fallback, so automatically build it from English to avoid redundancy:
TARGET=../grails-app/i18n/messages.properties
echo "# --- DO NOT MODIFY --- auto-generated by i18n_update.sh" >$TARGET
cat ../grails-app/i18n/messages_common.properties >>$TARGET
echo "" >>$TARGET
cat ../grails-app/i18n/messages_en.properties >>$TARGET
cd ..
rm -r i18n-temp