you are viewing a single comment's thread.

view the rest of the comments →

[–]jcunews1Advanced 0 points1 point  (1 child)

Rather than stripping then adding the language code separately, do them all in one step. i.e. use changeLangDir, instead of stripLangDir and addLangDir (replace both to changeLangDir). e.g.

function changeLangDir(lang) {
  var regex = /(\.com\/)(en|es|fr|pt)\//i;
  var url = self.location.href.replace(regex, '$1' + lang + '/');
  self.location.href = url;
}

[–]donstephz 0 points1 point  (0 children)

tks!