diff options
author | Filip Komar <filip@mageia.org> | 2013-08-10 14:55:24 +0000 |
---|---|---|
committer | Filip Komar <filip@mageia.org> | 2013-08-10 14:55:24 +0000 |
commit | 4e92fedb5a6314351b255ae19d64227339b95274 (patch) | |
tree | c4524a4585359adb8d24ac416a6ecab0470aa402 | |
parent | fc6c1393fde5eba8d2491d3510e3bd4ecea69cd3 (diff) | |
download | www-4e92fedb5a6314351b255ae19d64227339b95274.tar www-4e92fedb5a6314351b255ae19d64227339b95274.tar.gz www-4e92fedb5a6314351b255ae19d64227339b95274.tar.bz2 www-4e92fedb5a6314351b255ae19d64227339b95274.tar.xz www-4e92fedb5a6314351b255ae19d64227339b95274.zip |
report page extended to show duplicate strings in lang files
-rw-r--r-- | langs.inc.php | 11 | ||||
-rw-r--r-- | langs/diff.php | 2 | ||||
-rw-r--r-- | langs/lib.php | 10 | ||||
-rw-r--r-- | langs/report.php | 10 |
4 files changed, 24 insertions, 9 deletions
diff --git a/langs.inc.php b/langs.inc.php index b06cfed04..da15b73d4 100644 --- a/langs.inc.php +++ b/langs.inc.php @@ -338,10 +338,11 @@ class i18n * Get all locales from given file. * * @param string $file + * @param string $return_duplicates optional switch * * @return array */ - public static function _lang_return($file) + public static function _lang_return($file, $return_duplicates = false) { $strings = array(); @@ -356,9 +357,15 @@ class i18n if ($C === ';' && !empty($f[$k+1])) { $j = trim(substr($v, 1)); $j = str_replace(array("\'", "\""), array("'", '"'), $j); + if ($return_duplicates && !empty($strings[$j])) { + $duplicates[] = $j; + } $strings[$j] = trim($f[$k+1]); } } + if (!empty($duplicates)) { + $strings['duplicates'] = $duplicates; + } } return $strings; @@ -404,5 +411,3 @@ function _e($s = null, $args = null) { return i18n::_e($s, $args); } function _h($s = null, $args = null, $tag = 'p') { return i18n::_h($s, $args, $tag); } function _lang_load($locale, $domain) { return i18n::_lang_load($locale, $domain); } - - diff --git a/langs/diff.php b/langs/diff.php index d56be7f8e..68e741cd4 100644 --- a/langs/diff.php +++ b/langs/diff.php @@ -65,7 +65,7 @@ if($license) { if($constitution || $license) { $s .= 'Please read <a href="https://wiki.mageia.org/en/Internationalisation_Team_%28i18n%29#Special_cases_of_web_pages">page on wiki for more information</a> about that.</p>'; } -foreach (array('missing' => 'missing strings', 'notrans' => 'untranslated strings', 'extra' => 'unused (old) strings') as $type => $name) { +foreach (array('missing' => 'missing strings', 'notrans' => 'untranslated strings', 'extra' => 'unused (old) strings', 'dup_str' => 'duplicate strings') as $type => $name) { if (count($diff[$type]) > 0) { $s .= sprintf('<h2>%d %s:</h2>', count($diff[$type]), $name); diff --git a/langs/lib.php b/langs/lib.php index db1fc21f5..091883292 100644 --- a/langs/lib.php +++ b/langs/lib.php @@ -21,13 +21,14 @@ include '../langs.inc.php'; function _lang_diff($a, $b) { $fa = i18n::_lang_return($a); - $fb = i18n::_lang_return($b); + $fb = i18n::_lang_return($b, true); // option to return duplicates + $duplicates = (isset($fb['duplicates']) ? array_pop($fb) : null); - $ret = array( +/* $ret = array( 'aCount' => count($fa), 'bCount' => count($fb), 'diff' => count($fa) - count($fb), - ); + ); unused var */ $missing = array(); $notrans = array(); @@ -53,7 +54,8 @@ function _lang_diff($a, $b) 'b' => count($fb), 'missing' => $missing, 'notrans' => $notrans, - 'extra' => $extra + 'extra' => $extra, + 'dup_str' => $duplicates, ); } diff --git a/langs/report.php b/langs/report.php index 9a3e6967a..05d002836 100644 --- a/langs/report.php +++ b/langs/report.php @@ -105,6 +105,7 @@ $test = _lang_diff($f, $langF); $num_of_untranslated_strings = count($test['notrans']); + $num_of_duplicated_strings = count($test['dup_str']); if ($link == 'about/constitution') { $dest_constitution = sprintf('%s/%s/%s/%s_%s.md', APP_ROOT, $l, 'about/constitution', 'mageia.org_statutes', $l); @@ -167,6 +168,9 @@ if (count($test['extra']) > 0) { $extra = ' <span class="small">' . sprintf($diff_link, $f, $l) . '+' . count($test['extra']) . '</a></span>'; } + if ($num_of_duplicated_strings > 0) { + $extra .= ' <span class="small">' . sprintf($diff_link, $f, $l) . 'dup: ' . $num_of_duplicated_strings . '</a></span>'; + } $cols .= sprintf('<td class="ok"><a href="%s" title="get a copy of the file">OK</a>%s%s</td>', $langF, $extra, $link); @@ -192,7 +196,11 @@ $cols .= $num_of_untranslated_strings . ' untranslated<br>'; } if (count($test['extra']) > 0) { - $cols .= count($test['extra']) . ' extra'; + $cols .= count($test['extra']) . ' extra<br>'; + } + if ($num_of_duplicated_strings > 0) { + $cols .= $num_of_duplicated_strings . ' duplicate'; + $cols .= ($num_of_duplicated_strings > 1 ? 's' : ''); } $cols .= '</a>'; $cols .= $link . '</td>'; |