diff --git a/dev/translation/sanity_check_en_langfiles.php b/dev/translation/sanity_check_en_langfiles.php index 17dab085259..b1ccca39dee 100644 --- a/dev/translation/sanity_check_en_langfiles.php +++ b/dev/translation/sanity_check_en_langfiles.php @@ -1,5 +1,5 @@ +/* Copyright (c) 2015 Tommaso Basilici * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -15,8 +15,129 @@ * along with this program. If not, see . */ +echo ""; +echo ""; + +echo ""; + +echo ""; +echo "

If you call this file with the argument \"?unused=true\" it searches for the translation strings that exist in en_US but are never used

"; +echo "

IMPORTANT: that can take quite a lot of time (up to 10 minutes), you need to tune the max_execution_time on your php.ini accordingly

"; +echo "

Happy translating :)

"; + +// directory containing the php and lang files +$htdocs = "../../htdocs/"; // directory containing the english lang files -$workdir = "../../htdocs/langs/en_US/"; +$workdir = $htdocs."langs/en_US/"; $files = scandir($workdir); $exludefiles = array('.','..','README'); @@ -36,6 +157,7 @@ foreach ($files AS $file) { $row_array = explode('=',$row); $langstrings_3d[$path_file['basename']][$line+1]=$row_array[0]; $langstrings_full[]=$row_array[0]; + $langstrings_dist[$row_array[0]]=$row_array[0]; } } } @@ -53,8 +175,48 @@ foreach ($langstrings_3d AS $filename => $file) { } } -echo "

Duplicate strings in lang files in $workdir

"; +echo "

Duplicate strings in lang files in $workdir - ".count($dups)." found

"; echo "
";
-print_r($dups);
 
+echo " ";
+echo "";
+echo "";
+$count = 0;
+foreach ($dups as $string => $pages) {
+	$count++;
+	echo "";
+	echo "";
+	echo "";
+	echo "";
+}
+echo "";
+echo "
#StringFile and lines
$count$string"; + foreach ($pages AS $page => $lines ) { + echo "$page "; + foreach ($lines as $line => $nothing) { + echo "($line) "; + } + echo "
"; + } + echo "
"; + + +if ($_REQUEST['unused'] == 'true') { + + foreach ($langstrings_dist AS $value){ + $search = '\'trans("'.$value.'")\''; + $string = 'grep -R -m 1 -F --include=*.php '.$search.' '.$htdocs.'*'; + exec($string,$output); + if (empty($output)) { + $unused[$value] = true; + echo $value.'
'; + } + } + + echo "

Strings in en_US that are never used

"; + echo "
";
+	print_r($unused);
+}
+echo "";
+echo "";
 ?>
\ No newline at end of file