Merge branch 'QA_3_3'
[phpmyadmin/dkf.git] / scripts / find_unused_messages.sh
blobc557c0dae84b4fb16c656788f558a6f4617020bc
1 #!/bin/sh
3 export LANG=C
4 set -e
6 # Simple script to find unused message strings by Michal Čihař
8 tmp1=`mktemp`
9 tmp2=`mktemp`
10 grep -o '^\$\<str[A-Z][a-zA-Z0-9_]*\>' libraries/messages.inc.php \
11 | tr -d '$' \
12 | grep -Ev '^str(Transformation_|ShowStatus)' | sort -u > $tmp1
13 grep -ho '\<str[A-Z][a-zA-Z0-9_]*\>' `find . -type f -a -name '*.php' -a -not -path '*/libraries/messages.inc.php'` \
14 | grep -Ev '^str(Transformation_|ShowStatus|Setup)' | sort -u > $tmp2
16 echo Please note that you need to check results of this script, it doesn\'t
17 echo understand PHP, it only tries to find what looks like message name.
19 echo
20 echo Used messages not present in messages file:
21 echo '(this contains generated messages and composed message names, so these'
22 echo 'are not necessary a errors!)'
23 echo
25 # filter out known false positives
26 diff $tmp1 $tmp2 | awk '/^>/ {print $2}' | grep -Ev '(strEncto|strXkana|strDBLink|strPrivDesc|strPrivDescProcess|strTableListOptions|strMissingParameter|strAttribute|strDoSelectAll)'
28 echo
29 echo Not used messages present in messages file:
30 echo
32 diff $tmp1 $tmp2 | awk '/^</ {print $2}' | grep -Ev '(strSetup.*_(desc|name)|strSetupForm_|strSetupFormset_)'
35 rm -f $tmp1 $tmp2