/** * @dataProvider getUserBaseCoverageDP */ public function testgetUserBaseCoverage($a, $b, $c) { $obj = new _Project(); $this->string($obj->getUserBaseCoverage($a, $b))->isEqualTo($c); }
if (!file_exists(Project::getLocalFilePath($current_website, $current_locale, $current_filename))) { // If the raw file does not exist, just skip the locale for this file continue; } $file_analysis = RawManager::compareRawFiles($current_website, $current_locale, $current_filename); $cmp_result = $file_analysis['cmp_result']; if ($cmp_result == 'ok') { $complete_locales_count++; $complete_locales_list[] = $current_locale; } $json_data[$current_filename][$current_locale]['status'] = $cmp_result; $website_name = Project::getWebsiteName($current_website); $locale_link = "<a href='./?locale={$current_locale}#{$website_name}'>{$current_locale}</a>"; echo "\n <tr>\n <td class='maincolumn'>{$locale_link}</td>\n <td><span class='rawstatus {$cmp_result}'>" . str_replace('_', ' ', $cmp_result) . "</span></td>\n </tr>\n"; } $coverage = Project::getUserBaseCoverage($complete_locales_list, $adu) . '%'; echo ' </tbody> <tfoot> <tr> <td colspan= "2">' . $complete_locales_count . ' translated locales (' . round($complete_locales_count / count($supported_locales) * 100) . '%)<br>' . $coverage . ' of our l10n user base' . '</td> </tr> </tfoot> </table> '; } $htmlresult = ob_get_contents(); ob_clean(); if ($json) { if ($locale == 'all' || $locale == '') { echo Json::output($json_data, false, true);
<?php namespace Langchecker; use Transvision\Json; if (!isset($_GET['locales'])) { die(Json::invalidAPICall('ERROR: missing list of locales.')); } $locales = $_GET['locales']; if (!is_array($locales)) { die(Json::invalidAPICall('ERROR: locales is not an array.')); } echo Project::getUserBaseCoverage($locales, $adu);
echo "<span class='taglist' {$style}>{$tag_text}</span>\n"; } echo "</p>"; } echo "<h2>{$current_filename}</h2>\n\n"; $counter = 0; foreach ($all_strings as $string_id => $available_translations) { // Display paragraph with reference string $header_string = trim(htmlspecialchars($string_id)); if (isset($tag_bindings[$string_id])) { $current_tag = $tag_bindings[$string_id]; $tag_number = array_search($current_tag, $available_tags); $style = "style='background-color: {$bg_colors[$tag_number]}; color: {$font_colors[$tag_number]};'"; $header_string .= "</a><span title='Associated tag' class='tag' {$style}>" . $current_tag . "</span>"; } else { $header_string .= "</a>"; } echo "<p id='string{$counter}'><a href='#string{$counter}' style='color: #008000;' onclick='showhide(\"{$counter}\");'>{$header_string}</p>\n"; // Display sub-table with localizations for this string echo "<table style='width:100%; display: {$show_status};' id='table{$counter}' class='translations'>\n"; $total_translations = count($available_translations); $covered_locales = array_keys($available_translations); $displayed_rows = 0; foreach ($available_translations as $current_locale => $translation) { $css_class = $displayed_rows & 1 ? 'odd_row' : 'even_row'; echo "<tr class='{$css_class}'>\n" . " <th>{$current_locale}</th>\n" . " <td>" . htmlspecialchars($translation) . "</td>\n" . "</tr>\n"; $displayed_rows++; } echo "<tr>\n <td colspan='2' class='donelocales_cell'>Number of locales done: {$total_translations}" . ' (' . Project::getUserBaseCoverage($covered_locales, $adu) . '% of our l10n user base)' . " </td>\n</tr>\n</table>\n"; $counter++; }