I am trying to do a simple replace of a string.
function LanguageSwitch (lang) {
var pathname = window.location.pathname;
if (lang == "da") {
pathname = pathname.replace(array("/de/", "/en/"), "/da/");
}
if (lang == "en") {
pathname = pathname.replace(array("/da/", "/de/"), "/en/");
}
if (lang == "de") {
pathname = pathname.replace(array("/da/", "/en/"), "/de/");
}
window.location.replace(pathname);
}
this does work:
function LanguageSwitch (lang) {
var pathname = window.location.pathname;
if (lang == "da") {
pathname = pathname.replace("/en/", "/da/");
}
if (lang == "en") {
pathname = pathname.replace("/da/", "/en/");
}
window.location.replace(pathname);
}
but adding a third language selector - not so much ;-)
Any ideas.
EDIT: This is not a try to replace [x,y,z] with [a,b,c] but more an replace [x,y,z] with "a"