public function testOutdatedCompareRawFiles() { $obj = new _RawManager(); require_once TEST_FILES . 'config/sources.php'; $website = $sites[3]; $filename = 'email4.txt'; // Make localized file 1 hour older than reference file $referencefile = _Project::getLocalFilePath($website, 'en-US', $filename); $timestamp = filemtime($referencefile) - 3600; touch($referencefile); touch(_Project::getLocalFilePath($website, 'it', $filename), $timestamp); $file_analysis = $obj->compareRawFiles($website, 'it', $filename); $this->string($file_analysis['cmp_result'])->isEqualTo('outdated'); }
use Transvision\Json; // This view works only for snippets (website ID 6) $current_website = $sites[6]; $current_locale = $locale; $json_data = []; if ($locale == '') { exit(Json::invalidAPICall('Missing locale code in the request')); } if (!Project::isSupportedLocale($current_website, $current_locale)) { exit(Json::invalidAPICall('This locale is not supported for snippets')); } foreach (Project::getWebsiteFiles($current_website) as $current_filename) { if (!Project::isSupportedLocale($current_website, $current_locale, $current_filename, $langfiles_subsets)) { // File is not managed for this website+locale, ignore it continue; } if (!file_exists(Project::getLocalFilePath($current_website, $current_locale, $current_filename))) { // If the .lang file does not exist, just skip the locale for this file continue; } $locale_data = LangManager::loadSource($current_website, $current_locale, $current_filename); foreach ($locale_data['strings'] as $reference_string => $translated_string) { if ($reference_string != $translated_string) { // Interested only in translated strings, clean up {ok} $json_data[$reference_string] = Utils::cleanString($translated_string); } } } ksort($json_data); $callback = isset($_GET['callback']) ? $_GET['callback'] : false; exit(Json::output($json_data, $callback, true));
/** * @dataProvider selectViewDP */ public function testSelectView($a, $b) { $obj = new _Project(); $this->array($obj->selectView($a))->isEqualTo($b); }
} else { $file_analysis = RawManager::compareRawFiles($website, $current_locale, $filename); $cmp_result = $file_analysis['cmp_result']; $export_data[$website_name][$displayed_filename]['status'] = $cmp_result; } $export_data[$website_name][$displayed_filename]['data_source'] = $website_data_source; if (Project::isCriticalFile($website, $filename, $current_locale)) { $export_data[$website_name][$displayed_filename]['critical'] = true; } else { $export_data[$website_name][$displayed_filename]['critical'] = false; } // Flags if ($file_flags) { $export_data[$website_name][$displayed_filename]['flags'] = $file_flags; } // Stage URL $export_data[$website_name][$displayed_filename]['url'] = Project::getLocalizedURL($reference_data, $current_locale); // Some files have a deadline if (isset($deadline[$filename])) { $export_data[$website_name][$displayed_filename]['deadline'] = $deadline[$filename]; } } } } if ($serial) { header("Content-type:text/plain"); die(serialize($export_data)); } if ($json) { die(Json::output($export_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);
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);
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++; }
<?php namespace Langchecker; use Transvision\Json; $output_array = []; $lang_based_sites = Project::getWebsitesByDataType($sites, 'lang'); if ($website != '' && $filename != '') { if (isset($lang_based_sites[$website])) { $current_website = $lang_based_sites[$website]; $current_filename = $filename; if (in_array($current_filename, Project::getWebsiteFiles($current_website))) { $output_array = array_values(Project::getSupportedLocales($current_website, $current_filename, $langfiles_subsets)); } } } elseif ($project != '') { switch ($project) { case 'locamotion': $output_array = $locamotion_locales; break; case 'marketplacebadge': $output_array = $marketplacebadge_locales; break; case 'slogans': $output_array = $slogans_locales; break; case 'snippets': $output_array = $snippets_locales; break; case 'snippets_main': $output_array = $snippets_main_locales;