<?php

namespace Stores;

print \Transvision\Json::output($done);
// 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 (!file_exists(Project::getLocalFilePath($current_website, $current_locale, $current_filename))) {
                continue;
            }
            $reference_data = LangManager::loadSource($current_website, $reference_locale, $current_filename);
            $locale_analysis = LangManager::analyzeLangFile($current_website, $current_locale, $current_filename, $reference_data);
            $untranslated[$current_locale] += count($locale_analysis['Identical']) + count($locale_analysis['Missing']);
            $translated[$current_locale] += count($locale_analysis['Translated']);
            $file_count[$current_locale] += 1;
        }
    }
    $all_strings[$current_locale] = $untranslated[$current_locale] + $translated[$current_locale];
}
// I need locales with more untranslated strings first
arsort($untranslated);
if ($json) {
    die(Json::output($untranslated, false, true));
}
// General table with untranslated/translated strings per locale
$rows = '';
foreach ($untranslated as $locale => $untranslated_count) {
    if ($untranslated_count == 0) {
        $class = 'class="count_complete"';
    } else {
        $class = '';
    }
    $rows .= "<tr {$class}>" . "  <td><a href='./?locale={$locale}'>{$locale}</a></td>\n" . "  <td>{$untranslated_count}</td>\n" . "  <td>{$translated[$locale]}</td>\n" . "  <td>{$all_strings[$locale]}</td>\n" . "  <td>{$file_count[$locale]}</td>\n" . "</tr>\n";
}
$general_table = "\n<table class='sortable'>\n  <thead>\n    <tr>\n        <th>Locale</th>\n        <th>Untranslated</th>\n        <th>Translated</th>\n        <th>Total</th>\n        <th>Files</th>\n    </tr>\n  </thead>\n  <tbody>\n{$rows}\n  </tbody>\n  <tfooter>\n    <tr>\n        <th colspan='4'>Number of locales</th>\n        <td><strong>" . count($mozilla) . "</strong></td>\n    </tr>\n  </tfooter>\n</table>\n";
/* Summary table code */
// Those are tips displayed when hovering the row header
$title = ['perfect' => 'Everything is translated', 'good' => 'Less than 50 missing strings', 'average' => 'Between 50 and 200 missing strings', 'bad' => 'Between 200 and 500 missing strings', 'very bad' => 'More than 500 missing strings'];
<?php

namespace Stores;

print \Transvision\Json::output($locales);
Beispiel #5
0
 /**
  * @dataProvider outputDP
  */
 public function testOutput($a, $b, $c, $d)
 {
     $obj = new _Json();
     $this->string($obj->output($a, $b, $c))->isEqualTo($d);
 }
            } 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));
}
        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);
    } else {
        // Only one locale
        if (isset($json_data[$current_filename][$locale])) {
            $single_locale_json[$current_filename][$locale] = $json_data[$current_filename][$locale];
            echo Json::output($single_locale_json, false, true);
        } else {
            // Unknown locale
            die(Json::invalidAPICall("Unknown locale: {$locale}. Check the value and try again."));
        }
    }
} else {
    echo $htmlresult;
}
<?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);
$supported_locales = Project::getSupportedLocales($current_website, $current_filename, $langfiles_subsets);
foreach ($supported_locales as $current_locale) {
    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 ($reference_data['strings'] as $string_id => $string_value) {
        if (LangManager::isStringLocalized($string_id, $locale_data, $reference_data)) {
            $all_strings[$string_id][$current_locale] = Utils::cleanString($locale_data['strings'][$string_id]);
        }
    }
}
// If request output is JSON, we're ready
if ($json) {
    die(Json::output($all_strings, false, true));
}
// Colors used to display tags
$bg_colors = ['#459E09', '#B29EF9', '#2D68BA', '#E39530', '#D6D6D4', '#E3309E', '#FF4040', '#F5F562', '#F562C7', '#C0FCF2'];
$font_colors = ['#FFF', '#FFF', '#FFF', '#FFF', '#000', '#FFF', '#FFF', '#000', '#FFF', '#000'];
if (isset($reference_data['tag_bindings'])) {
    $tag_bindings = $reference_data['tag_bindings'];
    // I want keys in $available_tags to be progressive
    $available_tags = array_values(array_unique(array_values($tag_bindings)));
} else {
    $tag_bindings = [];
    $available_tags = [];
}
echo "<p>Click on the green English strings to expand/collapse the translations done</p>\n";
// Display all tags used in this page
if (count($available_tags) > 0) {
<?php

namespace Stores;

use Transvision\Json;
// Create our API object
$request = new API($url);
$response = new Json();
// Check if valid API call
if ($request->isValidRequest()) {
    include MODELS . 'api_model.php';
} else {
    $json = $response->output($request->invalidAPICall());
}
include VIEWS . 'json_view.php';
exit;
        $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;
            break;
    }
}
if (count($output_array) == 0) {
    // No locales: either wrong values or not enought parameters
    http_response_code(400);
    $output_array[] = 'Please check you request: provide a project name, or a valid couple website+file.';
}
echo Json::output($output_array, false, true);
<?php

namespace Stores;

print \Transvision\Json::output($mapping);
<?php

namespace Stores;

print \Transvision\Json::output($json);