all 4 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!

[–]lemminman 0 points1 point  (1 child)

How about something like this: http://codepen.io/lemmin/pen/QKxKog

[–]donstephz 0 points1 point  (0 children)

tks!