-
Notifications
You must be signed in to change notification settings - Fork 2
/
activity-translations
executable file
·82 lines (68 loc) · 1.82 KB
/
activity-translations
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/sh
# Public Domain
# Written by James Cameron <quozl@laptop.org> in 2017.
#
# usage: activity-translations ProjectName
# where ProjectName is one listed on translate.sugarlabs.org
#
usage(){
echo "usage: activity-translations ProjectName
where ProjectName is one listed on translate.sugarlabs.org"
}
# abandon if ProjectName argument isn't given
if [ $# -eq 0 ]; then
usage
exit 2
fi
A=$1
# abandon if there is no activity metadata here
if [ ! -e activity/activity.info ]; then
echo not an activity
exit 2
fi
# abandon if there is no po file here
if [ ! -e po ]; then
echo not internationalised
exit 2
fi
# check for tools needed
if [ ! -e /usr/bin/pcregrep ]; then
echo please install pcregrep
exit 2
fi
if [ ! -e /usr/bin/wget ]; then
echo please install wget
exit 2
fi
if [ ! -e /usr/bin/unzip ]; then
echo please install unzip
exit 2
fi
# fetch latest translations
cd po
wget https://translate.sugarlabs.org/projects/$A/
wget_status=$?
if [ "$wget_status" -ne 0 ] ; then
echo "Translations could not be fetched, wget failed."
if [ "$wget_status" -eq 8 ]; then
echo "Server error. Check if ProjectName is correct."
fi
exit 2
fi
for x in $(grep "/$A/translate/\"" index.html | \
cut -d/ -f2 | grep -v projects); do
echo $x
wget -q https://translate.sugarlabs.org/$x/$A/export/zip && \
unzip -q -o zip && \
rm -f zip
done
rm index.html
# remove empty translations
rm -f $(find . -type f -name '*.po' -not -execdir pcregrep -qM '^msgstr[^:]* "([^"]|"\n"(?!Project-Id-Version:))' '{}' ';' -print | sort)
echo "Done! Synchronized with translate.sugarlabs.org"
# your next steps;
#
# review and commit the changes,
# run setup.py genpot, review, and commit the changes
#
# please discard trivial changes, to avoid git commit noise