The Android Open Source Project | 52d4c30 | 2009-03-03 19:29:09 -0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | if [ "$1" == "-h" ] |
| 4 | then |
| 5 | cat <<- EOH |
| 6 | Usage: $0 [-p] [folder] |
| 7 | -p option prints out unused strings, otherwise a total count is printed |
| 8 | folder option causes only that app folder to be scanned, default is to scan all folders onder apps/ |
| 9 | EOH |
| 10 | exit |
| 11 | fi |
| 12 | |
| 13 | showall=no |
| 14 | if [ "$1" == "-p" ] |
| 15 | then |
| 16 | showall=yes |
| 17 | shift |
| 18 | fi |
| 19 | |
| 20 | apps=$1 |
| 21 | if [ "$apps" == "" ] |
| 22 | then |
| 23 | apps=$ANDROID_BUILD_TOP/packages/apps/* |
| 24 | fi |
| 25 | |
| 26 | for app in $apps |
| 27 | do |
| 28 | if [ -d $app/res ] |
| 29 | then |
| 30 | pushd $app > /dev/null |
| 31 | for i in $(grep -R "\(string\|plurals\) name=" res | sed 's/.*<\(string\|plurals\) name="//'|sed 's/".*$//'|sort -u) |
| 32 | do |
| 33 | echo $i $(grep -Rw R.plurals.$i\\\|R.string.$i\\\|@string/$i .|wc -l) |
| 34 | done | grep ' 0$' | { |
| 35 | if [ "$showall" == "yes" ] |
| 36 | then |
| 37 | echo $app |
| 38 | cat |
| 39 | else |
| 40 | count=$(wc -l) |
| 41 | if [ "$count" != "0" ] |
| 42 | then |
| 43 | echo $app: $count unused strings |
| 44 | fi |
| 45 | fi |
| 46 | } |
| 47 | popd $app > /dev/null |
| 48 | fi |
| 49 | done |