Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions _includes/2020/templates/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ public static function render(array $fields): void {
}

/**
* Modify link of the current URL for a given UI language
* Modify link of the current URL for a given UI language.
* Skip if current URL isn't localized (e.g. _legacy)
* @param language - language tag to use
* @return string - modified URL
*/
Expand All @@ -45,15 +46,13 @@ private static function change_ui_language($language): string {

$path = '';
// Replace language if current language in path is valid BCP-47
// Note: Validate::validate_bcp47 differs from regex in .htaccess
if (!empty($parts['path'])) {
$path = explode("/", $parts['path']);
if ($path[1] != null ) {
/* TODO: add validation back && class_exists('\\Keyman\\Site\\com\\keyman\\Validation') &&
\Keyman\Site\com\keyman\Validation::validate_bcp47($path[1]) != null*/
if ($path[1] == Locale::pageLocale()) {
$path[1] = $language;
} else {
// original URL didn't have a valid BCP-47 so inert it
} else if (preg_match('/^\/(_legacy)\/.*$/i', $path[1], $matches)) {
// original URL didn't have a valid BCP-47, so insert new langage
// Skip for certain paths like: _legacy
array_splice($path, 1, 0, $language);
}
}
Expand Down
Loading