Skip to content

Commit 4d34eb1

Browse files
committed
js/locale: fix language switcher.
Correctly handle switching from non-English to another non-English page.
1 parent 2405f13 commit 4d34eb1

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

assets/js/locale.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ $(document).ready(function() {
55
});
66

77
function loadLanguage(lang) {
8+
base_pathname = window.location.pathname.replace(/^\/[a-z]+([_-][a-z]+)?\//, "/")
89
if (lang === "en") {
9-
url = window.location.pathname.replace(/^\/[a-z]+([_-][a-z]+)?\//, "/")
10+
url = base_pathname
1011
} else {
11-
url = "/" + lang + window.location.pathname
12+
url = "/" + lang + base_pathname
1213
}
1314
window.location.assign(url);
1415
}

0 commit comments

Comments
 (0)