From 25eeff4f199a0d63b003fbe7d1e1fd666c2fd3f0 Mon Sep 17 00:00:00 2001 From: Tommaso Basilici Date: Sat, 18 Apr 2015 15:12:06 +0200 Subject: [PATCH] first commit to fix issue #2584 - checks for duplicate lang strings across all en_US lang files --- dev/translation/sanity_check_en_langfiles.php | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 dev/translation/sanity_check_en_langfiles.php diff --git a/dev/translation/sanity_check_en_langfiles.php b/dev/translation/sanity_check_en_langfiles.php new file mode 100644 index 00000000000..b39108ab746 --- /dev/null +++ b/dev/translation/sanity_check_en_langfiles.php @@ -0,0 +1,60 @@ + +* +* 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 +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ + +// directory containing the english lang files +$workdir = "../../htdocs/langs/en_US/"; + +$files = scandir($workdir); +$exludefiles = array('.','..','README'); +$files = array_diff($files,$exludefiles); +$langstrings_3d = array(); +$langstrings_full = array(); +foreach ($files AS $file) { + $path_file = pathinfo($file); + // we're only interested in .lang files + if ($path_file['extension']=='lang') { + $content = file($workdir.$file); + foreach ($content AS $line => $row) { + // don't want comment lines + if (substr($row,0,1) !== '#') { + // don't want lines without the separator (why should those even be here, anyway...) + if (strpos($row,'=')!==false) { + $row_array = explode('=',$row); + $langstrings_3d[$path_file['basename']][$line+1]=$row_array[0]; + $langstrings_full[]=$row_array[0]; + } + } + } + } +} + +foreach ($langstrings_3d AS $filename => $file) { + foreach ($file AS $linenum => $value) { + $keys = array_keys($langstrings_full, $value); + if (count($keys)>1) { + foreach ($keys AS $key) { + $dups[$value][$filename] = $linenum; + } + } + } +} + +echo "

Duplicate strings in lang files in $workdir

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