This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Doc: Language switch can't switch on specific cases
Type: Stage: resolved
Components: Versions:
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: mdk, vstinner
Priority: normal Keywords:

Created on 2017-08-09 11:38 by mdk, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 3039 merged python-dev, 2017-08-09 11:53
PR 3051 merged python-dev, 2017-08-10 14:15
PR 3081 merged python-dev, 2017-08-13 10:33
Messages (6)
msg299990 - (view) Author: Julien Palard (mdk) * (Python committer) Date: 2017-08-09 11:38
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})?/)';
msg300016 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-08-09 15:01
New changeset 122081deef86174beee965be1207fa46ea23533d by Victor Stinner (Julien Palard) in branch 'master':
bpo-31159: fix language switch regex on unknown yet built languages. (#3039)
https://github.com/python/cpython/commit/122081deef86174beee965be1207fa46ea23533d
msg300056 - (view) Author: Julien Palard (mdk) * (Python committer) Date: 2017-08-10 07:26
Now works in 3.7, needs backports to 3.6 and 2.7.
msg300095 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-08-10 14:54
New changeset e8e7fba0b24582959feca9c31f2a72fc0251f83d by Victor Stinner (Julien Palard) in branch '3.6':
bpo-31159: fix language switch regex on unknown yet built languages. … (#3051)
https://github.com/python/cpython/commit/e8e7fba0b24582959feca9c31f2a72fc0251f83d
msg300232 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-08-13 21:44
New changeset fe8d9dc479a96ef490034107e7d4a6228b4be140 by Victor Stinner (Julien Palard) in branch '2.7':
bpo-31159: fix language switch regex on unknown yet built languages. … (#3051) (#3081)
https://github.com/python/cpython/commit/fe8d9dc479a96ef490034107e7d4a6228b4be140
msg300233 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-08-13 21:48
To choose the langague, see what Wikipedia does: Wikipedia EN displays
"Français", no?
History
Date User Action Args
2022-04-11 14:58:49adminsetgithub: 75342
2017-09-23 16:36:28mdksetstatus: open -> closed
stage: resolved
2017-08-13 21:48:21vstinnersetmessages: + msg300233
2017-08-13 21:44:54vstinnersetmessages: + msg300232
2017-08-13 10:33:36python-devsetpull_requests: + pull_request3123
2017-08-10 14:54:29vstinnersetmessages: + msg300095
2017-08-10 14:15:44python-devsetpull_requests: + pull_request3098
2017-08-10 07:26:13mdksetmessages: + msg300056
2017-08-09 15:01:18vstinnersetnosy: + vstinner
messages: + msg300016
2017-08-09 11:53:46python-devsetpull_requests: + pull_request3072
2017-08-09 11:38:46mdkcreate