From f3caa70e17e2fa3c3128e459237de4c8ec4c1b39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Sat, 8 Oct 2005 14:42:43 +0000 Subject: [PATCH] complete rewrite, now much faster and finds also unset messages --- scripts/find_unused_messages.sh | 37 +++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/scripts/find_unused_messages.sh b/scripts/find_unused_messages.sh index 7c1ca71f0..e5c0efd5e 100755 --- a/scripts/find_unused_messages.sh +++ b/scripts/find_unused_messages.sh @@ -2,15 +2,30 @@ # Simple script to find unused message strings by Michal Čihař -phpfiles=`find . -type f -a -name '*.php' -a -not -path '*/lang/*'` +tmp1=`mktemp` +tmp2=`mktemp` +grep -o '\' lang/english-iso-8859-1.inc.php \ + | grep -Ev '^str(Transformation_|ShowStatus)' | sort -u > $tmp1 +grep -ho '\' `find . -type f -a -name '*.php' -a -not -path '*/lang/*'` \ + | grep -Ev '^str(Transformation_|ShowStatus)' | sort -u > $tmp2 -grep -o 'str[A-Z][a-zA-Z_]*' lang/english-iso-8859-1.inc.php \ - | grep -Ev '^str(Transformation_|ShowStatus)' \ - | while read x - do - echo "Checking for $x" >&2 - if [ `grep -r "\\<$x\\>" $phpfiles | wc -l` -eq 0 ] - then - echo $x - fi - done +echo Please note that you need to check results of this script, it doesn\'t +echo understand PHP, it only tries to find what looks like message name. + +echo +echo Used messages not present in english language file: +echo '(this contains generated messages and composed message names, so these' +echo 'are not necessary a errors!)' +echo + +# filter out known false positives +diff $tmp1 $tmp2 | awk '/^>/ {print $2}' | grep -Ev '(strEncto|strXkana|strDBLink|strPrivDesc|strPrivDescProcess|strTableListOptions|strMissingParameter|strAttribute)' + +echo +echo Not used messages present in english language file: +echo + +diff $tmp1 $tmp2 | awk '/^