/** * Generate a path to the mercurial repo for the file * * @param string $locale locale code * @param string $repo repository name * @param string $path Entity name representing the local file * @return string Path to the file in remote mercurial repository */ public static function hgPath($locale, $repo, $path) { $url = 'https://hg.mozilla.org'; // remove entity from path and store it in a variable $path = explode(':', $path); $path = $path[0]; $path = explode('/', $path); $entity_file = array_pop($path); $path = implode('/', $path); $exploded_path = explode('/', $path); $base_folder = $exploded_path[0]; if (Strings::startsWith($repo, 'gaia') || in_array($base_folder, ['apps', 'shared', 'showcase_apps', 'test_apps', 'test_external_apps'])) { $locale = Project::getLocaleInContext($locale, $repo); if ($repo == 'gaia') { $url .= '/gaia-l10n/' . $locale . '/file/default/'; } else { $version = str_replace('gaia_', '', $repo); $url .= '/releases/gaia-l10n/v' . $version . '/' . $locale . '/file/default/'; } return $url . $path . '/' . $entity_file; } $en_US_Folder_Mess = ['b2g/branding/official/', 'b2g/branding/unofficial/', 'b2g/', 'netwerk/', 'embedding/android/', 'testing/extensions/community/chrome/', 'intl/', 'extensions/spellcheck/', 'services/sync/', 'mobile/android/branding/aurora/', 'mobile/android/branding/official/', 'mobile/android/branding/nightly/', 'mobile/android/branding/unofficial/', 'mobile/android/branding/beta/', 'mobile/android/base/', 'mobile/android/', 'mobile/', 'security/manager/', 'toolkit/content/tests/fennec-tile-testapp/chrome/', 'toolkit/', 'browser/branding/aurora/', 'browser/branding/official/', 'browser/branding/nightly/', 'browser/branding/unofficial/', 'browser/', 'devtools/client/', 'devtools/shared/', 'layout/tools/layout-debug/ui/', 'dom/', 'webapprt/', 'chat/', 'suite/', 'other-licenses/branding/thunderbird/', 'mail/branding/aurora/', 'mail/branding/nightly/', 'mail/', 'mail/test/resources/mozmill/mozmill/extension/', 'editor/ui/', 'calendar/']; // Destop repos if ($locale != 'en-US') { if ($repo == 'central') { $url .= '/l10n-central/' . $locale . '/file/default/'; } else { $url .= '/releases/l10n/mozilla-' . $repo . '/' . $locale . '/file/default/'; } } else { if (in_array($base_folder, ['calendar', 'chat', 'editor', 'ldap', 'mail', 'mailnews', 'suite'])) { $repo_base = 'comm'; } else { $repo_base = 'mozilla'; } if ($repo == 'central') { $url .= "/{$repo_base}-central/file/default/"; } else { $url .= "/releases/{$repo_base}-{$repo}/file/default/"; } $loop = true; while ($loop && count($exploded_path) > 0) { if (in_array(implode('/', $exploded_path) . '/', $en_US_Folder_Mess)) { $path_part1 = implode('/', $exploded_path) . '/locales/en-US'; $pattern = preg_quote(implode('/', $exploded_path), '/'); $path = preg_replace('/' . $pattern . '/', $path_part1, $path, 1); $loop = false; break; } else { array_pop($exploded_path); } } if ($loop == true) { $path = explode('/', $path); $category = array_shift($path); $path = $category . '/locales/en-US/' . implode('/', $path); } } return $url . $path . '/' . $entity_file; }
$whole_word = $check['whole_word'] ? '\\b' : ''; $delimiter = '~'; $main_regex = $delimiter . $whole_word . $my_search . $whole_word . $delimiter . $case_sensitive; // build the repository switcher $repo_list = Utils::getHtmlSelectOptions($repos_nice_names, $check['repo'], true); // Get the locale list for every repo and build his target/source locale switcher values. $loc_list = []; $source_locales_list = []; $target_locales_list = []; $repositories = Project::getRepositories(); foreach ($repositories as $repository) { $loc_list[$repository] = Project::getRepositoryLocales($repository); // build the source locale switcher $source_locales_list[$repository] = Utils::getHtmlSelectOptions($loc_list[$repository], Project::getLocaleInContext($source_locale, $repository)); // build the target locale switcher $target_locales_list[$repository] = Utils::getHtmlSelectOptions($loc_list[$repository], Project::getLocaleInContext($locale, $repository)); // 3locales view: build the target locale switcher for a second locale $target_locales_list2[$repository] = Utils::getHtmlSelectOptions($loc_list[$repository], Project::getLocaleInContext($locale2, $repository)); } // Build the search type switcher $search_type_descriptions = ['strings' => 'Strings', 'entities' => 'Entities', 'strings_entities' => 'Strings & Entities']; $search_type_list = Utils::getHtmlSelectOptions($search_type_descriptions, $check['search_type'], true); // Get COOKIES $get_cookie = function ($var) { return isset($_COOKIE[$var]) ? $_COOKIE[$var] : ''; }; $cookie_repository = $get_cookie('default_repository'); $cookie_source_locale = $get_cookie('default_source_locale'); $cookie_target_locale = $get_cookie('default_target_locale'); $cookie_target_locale2 = $get_cookie('default_target_locale2'); $cookie_search_type = $get_cookie('default_search_type');
// Redirect locale to a different one if necessary $requested_locale = $_GET['locale']; $requested_locale = Project::getLocaleInContext($requested_locale, $repo); if (in_array($requested_locale, $all_locales)) { $l10n->setDefaultLocale($requested_locale); $locale = $l10n->getDefaultLocale(); } } // Bypass locale detection if the page sends a valid GET variable if (isset($_GET['locale2'])) { // Redirect locale to a different one if necessary $requested_locale2 = $_GET['locale2']; $requested_locale2 = Project::getLocaleInContext($requested_locale2, $repo); if (in_array($requested_locale2, $all_locales)) { $locale2 = $requested_locale2; } } // Bypass default source locale for locale to locale comparison if (isset($_GET['sourcelocale'])) { // Redirect locale to a different one if necessary $requested_sourcelocale = $_GET['sourcelocale']; $requested_sourcelocale = Project::getLocaleInContext($requested_sourcelocale, $repo); if (in_array($requested_sourcelocale, $all_locales)) { $source_locale = $requested_sourcelocale; } } // Get rtl attribute for source and target locales $locale_dir = $l10n->getDirection($locale); $source_locale_dir = $l10n->getDirection($source_locale); // Initialize list of JavaScript files to include $javascript_include = [];