diff options
| author | Samuel Tardieu <sam@rfc1149.net> | 2011-10-08 09:25:44 +0200 |
|---|---|---|
| committer | Samuel Tardieu <sam@rfc1149.net> | 2011-10-08 09:32:35 +0200 |
| commit | 74d6ff56dbbf4b868a24a6b31ec296b48bc60273 (patch) | |
| tree | 373bfeb4ca09d9718e255e09d8621fb35c39aea8 /main/project/localization/findextratranslations.sh | |
| parent | 1455819e59d5e2fb55c5fcbc562b1cfdbe47a80d (diff) | |
| download | cgeo-74d6ff56dbbf4b868a24a6b31ec296b48bc60273.zip cgeo-74d6ff56dbbf4b868a24a6b31ec296b48bc60273.tar.gz cgeo-74d6ff56dbbf4b868a24a6b31ec296b48bc60273.tar.bz2 | |
Add an extra script to find and remove unused translation strings
Diffstat (limited to 'main/project/localization/findextratranslations.sh')
| -rwxr-xr-x | main/project/localization/findextratranslations.sh | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/main/project/localization/findextratranslations.sh b/main/project/localization/findextratranslations.sh new file mode 100755 index 0000000..56aedd3 --- /dev/null +++ b/main/project/localization/findextratranslations.sh @@ -0,0 +1,54 @@ +#!/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() { + (cd $sourcedir && grep -m 1 R.string.$1 $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 |
