$strings_locale = Utils::getRepoStrings($locale, $repo);
$strings_reference = Utils::getRepoStrings(Project::getReferenceLocale($repo), $repo);
// Filter out unwanted keys
foreach ($strings_reference as $string_id => $string_value) {
    if (strlen($string_value) <= 1 || strpos($string_id, 'region.properties') !== false) {
        /*
            Ignore accesskeys, shortcuts and empty strings.
            Ignore keys in region.properties
        */
        unset($strings_reference[$string_id]);
    }
}
// Find strings identical to English
$unchanged_strings = [];
foreach ($strings_reference as $string_id => $string_value) {
    if (isset($strings_locale[$string_id])) {
        // Compare only if the localized string exists
        if ($strings_locale[$string_id] == $string_value) {
            $unchanged_strings[$string_id] = $string_value;
        }
    }
}
if (in_array($repo, $desktop_repos)) {
    // Build logic to filter components
    $javascript_include = ['/js/component_filter.js'];
    $components = Project::getComponents($unchanged_strings);
    $filter_block = '';
    foreach ($components as $value) {
        $filter_block .= " <a href='#{$value}' id='{$value}' class='filter'>{$value}</a>";
    }
}
namespace Transvision;

$source = Utils::getRepoStrings(Project::getReferenceLocale($repo), $repo);
$target = Utils::getRepoStrings($locale, $repo);
// Set up channel selector, ignore mozilla.org
$channels = Project::getSupportedRepositories();
unset($channels['mozilla_org']);
$channel_selector = Utils::getHtmlSelectOptions($channels, $repo, true);
// Build the target locale switcher
$target_locales_list = Utils::getHtmlSelectOptions(Project::getRepositoryLocales($repo), $locale);
$source = array_map(['Transvision\\AnalyseStrings', 'cleanUpEntities'], $source);
$target = array_map(['Transvision\\AnalyseStrings', 'cleanUpEntities'], $target);
// We need to ignore some strings because of false positives
$ignored_strings = ['mail/chrome/messenger/aboutRights.dtd:rights.webservices-term4', 'suite/chrome/branding/aboutRights.dtd:rights.webservices-term4', 'toolkit/chrome/global/aboutRights.dtd:rights.webservices-term5'];
$var_errors = AnalyseStrings::differences($source, $target, $repo, $ignored_strings);
$error_count = count($var_errors);
// Add component filter
if (in_array($repo, $desktop_repos)) {
    // Build logic to filter components
    $javascript_include = ['component_filter.js'];
    $components = Project::getComponents(array_flip($var_errors));
    $filter_block = '';
    foreach ($components as $value) {
        $filter_block .= " <a href='#{$value}' id='{$value}' class='filter'>{$value}</a>";
    }
}
// RTL support
$direction1 = RTLSupport::getDirection($source_locale);
$direction2 = RTLSupport::getDirection($locale);
$bugzilla_base_link = 'https://bugzilla.mozilla.org/enter_bug.cgi?format=__default__&component=' . Bugzilla::getURLencodedBugzillaLocale($locale, 'products') . '&product=Mozilla%20Localizations&status_whiteboard=%5Btransvision-feedback%5D';
array_splice($locale1_strings, $limit_results);
array_splice($locale2_strings, $limit_results);
$searches = [$source_locale => $locale1_strings, $locale => $locale2_strings];
$data = [$tmx_source, $tmx_target];
// 3locales view
if ($url['path'] == '3locales') {
    $check['extra_locale'] = $locale2;
    $searches[$locale2] = $locale3_strings;
    $data[] = $tmx_target2;
}
$search_yields_results = false;
// This will hold the components names for the search filters
$components = [];
foreach ($searches as $key => $value) {
    $search_results = ShowResults::getTMXResults(array_keys($value), $data);
    $components += Project::getComponents($search_results);
    if (count($value) > 0) {
        // We have results, we won't display search suggestions but search results
        $search_yields_results = true;
        $search_id = strtolower(str_replace('-', '', $key));
        $message_count = $real_search_results > $limit_results ? "<span class=\"results_count_{$search_id}\">{$limit_results} results</span> out of {$real_search_results}" : "<span class=\"results_count_{$search_id}\">" . Utils::pluralize(count($search_results), 'result') . '</span>';
        $output[$key] = "<h2>Displaying {$message_count} for the string " . "<span class=\"searchedTerm\">{$initial_search_decoded}</span> in {$key}:</h2>";
        $output[$key] .= ShowResults::resultsTable($search_id, $search_results, $initial_search, $source_locale, $locale, $check);
    } else {
        $output[$key] = "<h2>No matching results for the string " . "<span class=\"searchedTerm\">{$initial_search_decoded}</span>" . " for the locale {$key}</h2>";
    }
}
// Remove duplicated components
$components = array_unique($components);
// Display a search hint for the closest string we have if we have no search results
if (!$search_yields_results) {