public function testCountErrors() { require_once TEST_FILES . 'config/sources.php'; $obj = new _LangManager(); $reference_data = $obj->loadSource($sites[2], 'en-US', 'page.lang'); $locale_data = $obj->loadSource($sites[2], 'it', 'page.lang'); $analysis_data = $obj->analyzeLangFile($sites[2], 'it', 'page.lang', $reference_data); $this->integer($obj->countErrors($analysis_data['errors'], 'all'))->isEqualTo(6); $this->integer($obj->countErrors($analysis_data['errors']))->isEqualTo(6); $this->integer($obj->countErrors($analysis_data['errors'], 'python'))->isEqualTo(5); $this->integer($obj->countErrors($analysis_data['errors'], 'length'))->isEqualTo(1); $this->integer($obj->countErrors($analysis_data['errors'], 'random'))->isEqualTo(0); }
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));
if (!Project::isSupportedLocale($website, $current_locale, $filename, $langfiles_subsets)) { // File is not managed for this website+locale, ignore it continue; } $reference_locale = Project::getReferenceLocale($website); $website_name = Project::getWebsiteName($website); $displayed_filename = $website_data_source == 'lang' ? $filename : basename($filename); $file_flags = Project::getFileFlags($website, $filename, $current_locale); if ($website_data_source == 'lang') { $locale_filename = Project::getLocalFilePath($website, $current_locale, $filename); if (!is_file($locale_filename) || Project::isObsoleteFile($website, $filename, $current_locale)) { // File is missing or marked as obsolete continue; } // Load reference strings $reference_data = LangManager::loadSource($website, $reference_locale, $filename); $locale_analysis = LangManager::analyzeLangFile($website, $current_locale, $filename, $reference_data); $export_data[$website_name][$displayed_filename]['identical'] = count($locale_analysis['Identical']); $export_data[$website_name][$displayed_filename]['missing'] = count($locale_analysis['Missing']); $export_data[$website_name][$displayed_filename]['obsolete'] = count($locale_analysis['Obsolete']); $export_data[$website_name][$displayed_filename]['translated'] = count($locale_analysis['Translated']); $export_data[$website_name][$displayed_filename]['errors'] = LangManager::countErrors($locale_analysis['errors']); } 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 {