Esempio n. 1
0
 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));
Esempio n. 3
0
 /**
  * @dataProvider getLocalFilePathDP
  */
 public function testLocalGetFilePath($a, $b, $c, $d)
 {
     $obj = new _Project();
     $this->string($obj->getLocalFilePath($a, $b, $c))->isEqualTo($d);
 }
Esempio n. 4
0
$export_data = [];
$current_locale = $locale;
foreach ($sites as $website) {
    if (Project::isSupportedLocale($website, $current_locale)) {
        $website_data_source = Project::getWebsiteDataType($website);
        foreach (Project::getWebsiteFiles($website) as $filename) {
            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'];