/** * @param array $languageUrlMap - ['language' => 'url', ..., 'default' => 'url'] */ public function route(array $languageUrlMap) { $language = $this->getBestMatch($this->languageList); $languageUrlMap['default'] = $languageUrlMap['default'] ?: '/404.php'; LanguageLink::setRootAlternateHeader($language); LocalRedirect($languageUrlMap[$language] ?: $languageUrlMap['default'], false, '301 Moved Permanently'); }
/** * @return array */ public function getLanguageList() { $languageList = []; foreach ($this->siteLanguageMap as $language => $languageRoot) { if ($language != LANGUAGE_ID) { LanguageLink::setAlternateHeader($language, LANGUAGE_ID, null); } $languageList[] = ['ID' => $language, 'NAME' => $this->nameLanguageMap[$language], 'URL' => LanguageLink::getLanguageLink($language, LANGUAGE_ID, null, true), 'ACTIVE' => $language == LANGUAGE_ID]; } return $languageList; }