New submission from Julien Palard:

Since ja has been added to the language switch, a bug appeared and in some case 
the switch won't ... switch.

Due to a regex bug in switchers.js, a needed trailing slash is sometimes not 
matched. It has not been detected previously as it can happen only when there 
more than two languages in the picker which is now the case.

Bug is in:  var language_regexp = '\.org/(' + 
Object.keys(all_languages).join('|') + '/)';

It only matches the trailing slash for the last language, currently the / is 
for ja, so fr does no longer match the needed slash.

Fix may consists in adding a non-matching group around the join.

But there's another issue when a user goes to a version in which there's a 
language picker but the current langage is not known by the picker, typically 
if a user is on /ja/2.7/ but the language picker with Japanese has only been 
merged on 3.6 and 3.7: the regex on /ja/2.7 will not contain "ja", so it will 
not be able to match it.

So we should write this regex otherwise, I grepped on the server logs and 
checked on the filesystem, this one should work better and still be safe:

    var language_regexp = '\.org/([a-z]{2}(?:-[a-z]{2})?/)';

messages: 299990
nosy: mdk
priority: normal
severity: normal
status: open
title: Doc: Language switch can't switch on specific cases

Python tracker <>
Python-bugs-list mailing list

Reply via email to