Skip to content

Commit 576ff8d

Browse files
committed
bpo-31159: fix language switch regex on unknown yet built languages. … (python#3051)
* bpo-31159: fix language switch regex on unknown yet built languages. (python#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. (python#3028) (cherry picked from commit c82b7f3) (cherry picked from commit e8e7fba)
1 parent 504939f commit 576ff8d

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)