diff options
author | Filip Komar <filip@mageia.org> | 2014-03-16 13:55:38 +0000 |
---|---|---|
committer | Filip Komar <filip@mageia.org> | 2014-03-16 13:55:38 +0000 |
commit | de07ef83d4ceb206a30d7bf6dbab6323bc0b02b1 (patch) | |
tree | 2b5e538176b9d27d9a008957b92a631956cd1480 | |
parent | cf636c606e93ed522ef2da9f8e41bc4c2f70fd1c (diff) | |
download | www-de07ef83d4ceb206a30d7bf6dbab6323bc0b02b1.tar www-de07ef83d4ceb206a30d7bf6dbab6323bc0b02b1.tar.gz www-de07ef83d4ceb206a30d7bf6dbab6323bc0b02b1.tar.bz2 www-de07ef83d4ceb206a30d7bf6dbab6323bc0b02b1.tar.xz www-de07ef83d4ceb206a30d7bf6dbab6323bc0b02b1.zip |
fixed proper handling of fuzzy strings in reports
-rw-r--r-- | langs/diff.php | 3 | ||||
-rw-r--r-- | langs/lib.php | 6 | ||||
-rw-r--r-- | langs/report.php | 32 |
3 files changed, 26 insertions, 15 deletions
diff --git a/langs/diff.php b/langs/diff.php index bc6e0ab5a..686b90ea7 100644 --- a/langs/diff.php +++ b/langs/diff.php @@ -71,6 +71,7 @@ if ($gettext) { $issues = array( 'missing' => 'missing strings', + 'fuzzy_or_missing' => 'fuzzy or missing strings', 'notrans' => 'untranslated strings', 'extra' => 'unused (old) strings', 'dup_str' => 'duplicate strings', @@ -115,7 +116,7 @@ $s .= '<p>After translation:</p> </ul>'; foreach ($issues as $type => $name) { - if (count($diff[$type]) > 0) { + if (isset($diff[$type]) && $diff[$type] > 0) { $s .= sprintf('<h2>%d %s:</h2>', count($diff[$type]), $name); $s .= '<pre>'; if ($type == 'untranslated_lines_in_constitution') { diff --git a/langs/lib.php b/langs/lib.php index 15f133131..cfc40cf28 100644 --- a/langs/lib.php +++ b/langs/lib.php @@ -88,7 +88,7 @@ function _po_diff($locale, $resource) $pot_strings = array(); $untrans = array(); - $missing = array(); + $fuzzy_or_missing = array(); foreach ($source_l as $escaped_string => $subarray) { if (!empty($subarray["msgid"])) { // filter out header @@ -108,14 +108,14 @@ function _po_diff($locale, $resource) $untrans[] = $escaped_string; } } else { - $missing[] = $escaped_string; + $fuzzy_or_missing[] = $escaped_string; } } return array( 'a' => count($pot_strings), // # of original strings // 'b' => count($po_strings), // # of target strings - 'missing' => $missing, + 'fuzzy_or_missing' => $fuzzy_or_missing, 'notrans' => $untrans, 'extra' => array(), 'dup_str' => array(), diff --git a/langs/report.php b/langs/report.php index 5725137d3..e0db9d987 100644 --- a/langs/report.php +++ b/langs/report.php @@ -51,6 +51,7 @@ $enFiles = array_merge(array('../_nav/langs/en.lang'), get_lang_references('*.lang'), get_lang_references('*.pot')); // added navigation file sort($enFiles); } + $num_of_enFiles = count($enFiles); if (isset($one_language) && $one_language != 'all') { $otherLangs = array('en', $one_language); @@ -131,11 +132,16 @@ if ($gettext) { $test = _po_diff($l, $resource); + $num_of_missing_strings = 0; + $num_of_fuzzy_or_missing_strings = count($test['fuzzy_or_missing']); } else { $test = _lang_diff($f, $langF); + $num_of_missing_strings = count($test['missing']); + $num_of_fuzzy_or_missing_strings = 0; } $num_of_untranslated_strings = count($test['notrans']); $num_of_duplicated_strings = count($test['dup_str']); + $num_of_extra_strings = count($test['extra']); if ($link == 'about/constitution') { $constitution_results = aproximate_number_of_untranslated_constitution_lines(G_APP_ROOT, $l, $unique_lines_in_eng_constitution); @@ -201,12 +207,13 @@ } $link .= $page_not_linked . '</div>'; - if (count($test['missing']) === 0 + if ($num_of_missing_strings === 0 + && $num_of_fuzzy_or_missing_strings === 0 && $num_of_untranslated_strings === 0) { $extra = null; - if (count($test['extra']) > 0) { - $extra = ' <span class="small">' . sprintf($diff_link, $f, $l) . '+' . count($test['extra']) . '</a></span>'; + if ($num_of_extra_strings > 0) { + $extra = ' <span class="small">' . sprintf($diff_link, $f, $l) . '+' . $num_of_extra_strings . '</a></span>'; } if ($num_of_duplicated_strings > 0) { $extra .= ' <span class="small">' . sprintf($diff_link, $f, $l) . 'dup: ' . $num_of_duplicated_strings . '</a></span>'; @@ -229,14 +236,17 @@ $cols .= sprintf('<td class="strings">' . $diff_link, $f, $l); - if (count($test['missing']) > 0) { - $cols .= count($test['missing']) . ' missing<br>'; + if ($num_of_missing_strings > 0) { + $cols .= $num_of_missing_strings . ' missing<br>'; + } + if ($num_of_fuzzy_or_missing_strings > 0) { + $cols .= $num_of_fuzzy_or_missing_strings . ' fuzzy or missing<br>'; } if ($num_of_untranslated_strings > 0) { $cols .= $num_of_untranslated_strings . ' untranslated<br>'; } - if (count($test['extra']) > 0) { - $cols .= count($test['extra']) . ' extra<br>'; + if ($num_of_extra_strings > 0) { + $cols .= $num_of_extra_strings . ' extra<br>'; } if ($num_of_duplicated_strings > 0) { $cols .= $num_of_duplicated_strings . ' duplicate'; @@ -244,7 +254,7 @@ } $cols .= '</a>'; $cols .= $link . '</td>'; - $done = $test['a'] - $num_of_untranslated_strings - count($test['missing']); + $done = $test['a'] - $num_of_untranslated_strings - $num_of_missing_strings - $num_of_fuzzy_or_missing_strings; } } $stats[$l]['strings'] += $done; @@ -256,7 +266,7 @@ } $num_clmns_to_repeat = 9; $num_of_col++; - if ($num_of_col % $num_clmns_to_repeat == 0 && $num_of_col <= count($enFiles) - ($num_clmns_to_repeat / 3)) { + if ($num_of_col % $num_clmns_to_repeat == 0 && $num_of_col <= $num_of_enFiles - ($num_clmns_to_repeat / 3)) { if ($l == 'en') { $cols .= $lang_coloumn = '<td style="font-weight: bold;">Language</td>'; } else { @@ -291,7 +301,7 @@ $lang_line = array(); $num_of_h_col = 0; $add_last_coloumn = FALSE; - $resources = ($restore_resources ? ' ' : count($enFiles) . ' resources'); + $resources = ($restore_resources ? ' ' : $num_of_enFiles . ' resources'); foreach ($enFiles as $lang_chunk) { $num_of_h_col++; if ($restore_resources) { @@ -299,7 +309,7 @@ } else { $lang_line[] = '<a href="?r=' . $lang_chunk . '" title="see only this resource">' . str_replace('en/', '', $lang_chunk) . '</a>'; } - if ($num_of_h_col % $num_clmns_to_repeat == 0 && $num_of_h_col <= count($enFiles) - ($num_clmns_to_repeat / 3)) { + if ($num_of_h_col % $num_clmns_to_repeat == 0 && $num_of_h_col <= $num_of_enFiles - ($num_clmns_to_repeat / 3)) { $lang_line[] = $resources; $add_last_coloumn = TRUE; } |