-
Notifications
You must be signed in to change notification settings - Fork 250
/
show-translation-percentage.sh
38 lines (30 loc) · 1.45 KB
/
show-translation-percentage.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
#!/bin/sh
# This script is only here to obtain quickly a very rough estimation of where we are (and for the fun of writing it, granted)
# Feel free to improve it or propose improvement on ML if you prefer
#extensible : could be used on -zh if wanted
translation=fr
totalSize=0
totalTranslatedSize=0
for englishVersion in hudsonbook-content/src/main/resources/*.xml
do
localeVersion=`echo $englishVersion| sed "s/hudsonbook-content/hudsonbook-content-\$translation/g"`
englishSize=`du -sk $englishVersion| cut -f1`
localeSize=`du -sk $localeVersion| cut -f1`
totalSize=$(( $englishSize + $totalSize ))
#echo "$englishVersion ($englishSize kb) -> $localeVersion ($localeSize kb)"
title=`grep "<title>" $englishVersion|head -1|sed "s/ *<title>//g"|sed "s/ *<\/title>//g"`
echo -n "$englishVersion: "
if [[ `diff $englishVersion $localeVersion` ]]
then
#Here we do a roughy-rough estimation of the proportion of lines having been translated.
#Any modified line between english and french is considered translated, obviously :-)
translatedSize=$(( `diff $englishVersion $localeVersion | egrep '^[<>]' | wc -c`/2000 ))
totalTranslatedSize=$(( $totalTranslatedSize + $translatedSize ))
#Note that sometimes, translation can be bigger than original, so display below can be disturbing :-) : 51/49 e.g.
echo -n "$translatedSize/$englishSize kB"
else
echo -n "Untouched yet."
fi
echo " (title: $title)"
done
echo "Summary: $totalTranslatedSize/$totalSize"