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 |
Michael Chan | 8d01416 | 2010-02-19 15:32:44 -0800 | [diff] [blame] | 31 | # Two sed's were needed because the | operator is not supported on the mac |
| 32 | for i in $(grep -Rs "\(string\|plurals\) name=" res | sed 's/.*string name=\"//' | sed 's/.*plurals name=\"//'|sed 's/".*$//'|sort -u) |
The Android Open Source Project | 52d4c30 | 2009-03-03 19:29:09 -0800 | [diff] [blame] | 33 | do |
Marco Nelissen | 69b04ff | 2010-02-19 10:59:54 -0800 | [diff] [blame] | 34 | echo $i $(grep -Rws R.plurals.$i\\\|R.string.$i\\\|@string/$i .|wc -l) |
The Android Open Source Project | 52d4c30 | 2009-03-03 19:29:09 -0800 | [diff] [blame] | 35 | done | grep ' 0$' | { |
| 36 | if [ "$showall" == "yes" ] |
| 37 | then |
| 38 | echo $app |
| 39 | cat |
| 40 | else |
| 41 | count=$(wc -l) |
| 42 | if [ "$count" != "0" ] |
| 43 | then |
| 44 | echo $app: $count unused strings |
| 45 | fi |
| 46 | fi |
| 47 | } |
| 48 | popd $app > /dev/null |
| 49 | fi |
| 50 | done |