blob: 9615abcc3d90375bc443f2ae7c690aedbbe04a82 [file] [log] [blame]
The Android Open Source Project52d4c302009-03-03 19:29:09 -08001#!/bin/bash
2
3if [ "$1" == "-h" ]
4then
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
11fi
12
13showall=no
14if [ "$1" == "-p" ]
15then
16 showall=yes
17 shift
18fi
19
20apps=$1
21if [ "$apps" == "" ]
22then
23 apps=$ANDROID_BUILD_TOP/packages/apps/*
24fi
25
26for app in $apps
27do
28 if [ -d $app/res ]
29 then
30 pushd $app > /dev/null
Michael Chan8d014162010-02-19 15:32:44 -080031 # 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 Project52d4c302009-03-03 19:29:09 -080033 do
Marco Nelissen69b04ff2010-02-19 10:59:54 -080034 echo $i $(grep -Rws R.plurals.$i\\\|R.string.$i\\\|@string/$i .|wc -l)
The Android Open Source Project52d4c302009-03-03 19:29:09 -080035 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
50done