Opensource.guide: Language option's location not correct when deploy the site in a sub dir

Created on 25 Jan 2019  Â·  6Comments  Â·  Source: github/opensource.guide

The code at /assets/js/locale.js line 7:

function loadLanguage(lang) {
  base_pathname = window.location.pathname.replace(/^\/[a-z]+([_-][a-z]+)?\//, "/")
  if (lang === "en") {
    url = base_pathname
  } else {
    url = "/" + lang + base_pathname
  }
}

The url works fine if the project deploy in a root dir, but not work in the sub dir.

If I folk this project in my repo, it's gh-pages url is https://codinggirl.github.io/opensource.guide/, and the language select did not work rightly.

help wanted javascript

Most helpful comment

@codinggirl Would you be able to submit a pull request to fix this?

All 6 comments

Ulster Bank

Language option's location not correct when deploy the site in a sub dir #828
@codinggirl
codinggirl opened this issue 9 days ago • edited 9 days ago
The code at /assets/js/locale.js line 7:

function loadLanguage(lang) {
base_pathname = window.location.pathname.replace(/^\/[a-z]+([_-][a-z]+)?\//, "/")
if (lang === "en") {
url = base_pathname
} else {
url = "/" + lang + base_pathname
}
}
The url works fine if the project deploy in a root dir, but not work in the sub dir.

If I folk this project in my repo, it's gh-pages url is https://codinggirl.github.io/opensource.guide/, and the language select did not work rightly.

@codinggirl Would you be able to submit a pull request to fix this?

/assets/js/locale.js

Everest Wilhemsen Ammendment Final Warning

This was fixed by #1033 thanks @suga0828 for the fix and @codinggirl for reporting.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

leolleocomp picture leolleocomp  Â·  8Comments

Victorsj picture Victorsj  Â·  6Comments

zhaiyusci picture zhaiyusci  Â·  3Comments

nowshad-hasan picture nowshad-hasan  Â·  5Comments

BaseMax picture BaseMax  Â·  3Comments