/
i18n_update.sh
executable file
·48 lines (41 loc) · 1.91 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
45
46
47
48
#!/bin/bash
# Download latest translations from Transifex and copy them over the existing local files.
CURRENT_DIR=`pwd`
CURRENT_BASE=`basename $CURRENT_DIR`
if [ "$(basename $CURRENT_DIR)" != 'scripts' ]; then
echo "Error: Please start this script from inside the 'scripts' directory";
exit 1;
fi
# Transifex username and password
USERNAME=dnaber
PASSWORD=`cat ~/.transifex_password`
rm -I i18n-temp
mkdir i18n-temp
cd i18n-temp
SOURCE=downloaded.tmp
# List of languages in the same order as on https://www.transifex.com/projects/p/languagetool/:
# Do not list 'en', it's the source and taken from SVN.
for lang in ast be br ca zh da nl eo fr gl de el_GR it pl ru sl es tl uk ro sk sv is lt km pt_PT pt_BR ta fa
do
shortCode=$(echo "$lang" | sed -e 's/_.*//')
curl --user $USERNAME:$PASSWORD http://www.transifex.net/api/2/project/languagetool/resource/messagesbundleproperties/translation/$lang/?file >$SOURCE
recode latin1..utf8 $SOURCE
TARGET="../../../languagetool-language-modules/${shortCode}/src/main/resources/org/languagetool/MessagesBundle_${lang}.properties"
SOURCE2=downloaded.tmp.ascii
native2ascii $SOURCE >$SOURCE2
# ignore new strings not translated yet (Transifex adds them, but commented out):
modified_lines=`diff $TARGET $SOURCE2 | grep "^[<>]" | grep "^[<>] [a-zA-Z]"|wc -l`
if [ $modified_lines -ne "0" ]; then
# fix the comment for English, which doesn't make sense for the translations:
sed -i "s/^# English translation of LanguageTool/# DO NOT MODIFY MANUALLY - all changes are done at https:\/\/www.transifex.com\/projects\/p\/languagetool\//" $SOURCE2
sed -i "s/^# Copyright (C).*/# Copyright (C) 2006-2013 the LanguageTool team (http:\/\/www.languagetool.org)/" $SOURCE2
echo "Moving $SOURCE2 to $TARGET ($modified_lines lines modified)"
mv $SOURCE2 $TARGET
else
echo "No real modification in $lang"
rm $SOURCE
rm $SOURCE2
fi
done
cd ..
rm -r i18n-temp