Skip to content

Commit e8e7fba

Browse files
JulienPalardvstinner
authored andcommitted
bpo-31159: fix language switch regex on unknown yet built languages. … (#3051)
* bpo-31159: fix language switch regex on unknown yet built languages. (#3039) This fix a regex issue (a missing non-matching group around an 'or' list) and the specific possible case where a translation is built but not yet in known by the picker, but not explicitly listing possible languages in the regex. (cherry picked from commit 122081d) * bpo-31149: Doc: Add Japanese to the language switcher. (#3028) (cherry picked from commit c82b7f3)
1 parent 719a15b commit e8e7fba

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Doc/tools/static/switchers.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
var all_languages = {
2222
'en': 'English',
2323
'fr': 'Français',
24+
'ja': 'Japanese',
2425
};
2526

2627
function build_version_select(current_version, current_release) {
@@ -109,7 +110,7 @@
109110
// Returns the path segment of the language as a string, like 'fr/'
110111
// or '' if not found.
111112
function language_segment_from_url(url) {
112-
var language_regexp = '\.org/(' + Object.keys(all_languages).join('|') + '/)';
113+
var language_regexp = '\.org/([a-z]{2}(?:-[a-z]{2})?/)';
113114
var match = url.match(language_regexp);
114115
if (match !== null)
115116
return match[1];
@@ -119,7 +120,7 @@
119120
// Returns the path segment of the version as a string, like '3.6/'
120121
// or '' if not found.
121122
function version_segment_in_url(url) {
122-
var language_segment = '(?:(?:' + Object.keys(all_languages).join('|') + ')/)';
123+
var language_segment = '(?:[a-z]{2}(?:-[a-z]{2})?/)';
123124
var version_segment = '(?:(?:' + version_regexs.join('|') + ')/)';
124125
var version_regexp = '\\.org/' + language_segment + '?(' + version_segment + ')';
125126
var match = url.match(version_regexp);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy