Greetings,
I do realise that there’ve been threads on one button for two functions but the suggestions there didn’t really help.
I’m trying to create a button which onClick would change the currentLanguage AND go to the home page (kind of a hard reset button to counter the multilingual flaws (dynamic pages, databases)).
import wixWindow from 'wix-window';
import wixLocation from 'wix-location';
$w.onReady(function () {
$w("#languageEN").onClick((event) => {
if (wixWindow.multilingual.currentLanguage === "en") {
wixWindow.multilingual.currentLanguage = "ja";
} else {
wixWindow.multilingual.currentLanguage = "en";
}
})
$w('#languageEN').link = "/home";
});
With the above you either get redirected to /home with no language change, or if you are already on the home page, only then the language change occurs.
The code is in the Site Code tab.
I’ve also tried ↓ and some other variations but the result was the same as above.
export function languageEN_click(event) {
wixWindow.multilingual.currentLanguage = "ja";
wixLocation.to("/home");
}
Any heads up?