blob: 8e2898dcc84c45703c6b12f491c98d75be145478 (
plain)
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
|
#!/bin/sh
cd `dirname "$0"`
. ./funcs.sh
sourcedir=../../src/cgeo/geocaching
sourcefiles=`cd $sourcedir && find . -name '*.java'`
xmlfiles=`echo ../../res/*/*.xml ../../AndroidManifest.xml`
first=true
if [ x$1 = x-f ]; then
remove=true
elif [ x$1 = x-n ]; then
remove=false
else
echo "Usage: findextratranslations.sh [ -n | -f]" >&2
echo " -n: only display" >&2
echo " -f: force unused strings removal" >&2
exit 1
fi
checkpresent() {
# Attributes are a special case, where in fact only the _yes is
# referenced in the source while the _no should be kept as well
res=`echo $1 | sed -e 's/^\(attribute_.*_\)no/\1yes/'`
(cd $sourcedir && grep -m 1 R.string.$res $sourcefiles > /dev/null) || \
grep -m 1 @string/$1 $xmlfiles > /dev/null
}
checkname() {
if ! checkpresent $1; then
checkfirst
echo " - $1"
if $remove; then
remove_from_strings $1
fi
fi
}
remove_from_strings() {
sed -i -e "/<string name=\"$1\">/d" ../../res/values*/strings.xml
}
checkfirst() {
if $first; then
echo Possibly unreferenced names:
first=false
fi
}
for name in `getnames ../../res/values/strings.xml`; do
checkname $name
done
if $first; then
echo All names seem to be in use
fi
|