im doing some button that will change the language of my webpage,
at the begin is seems ok,
but after few hour of learning i found an issue.
issue example.
- page original state is english.
- put a button and add some code that will change entire page text and picture to other language.
- click button. it changed.
- after that , click other page it changed back to english again.
here are the code that i using.
let locale;
export function localEn_click_1(event, $w) {
$w(“#tncEn”).show();
$w(“#tncBm”).hide();
$w(“#tncCn”).hide();
$w(“#floatText”).text = “English Text”;
$w(“#bankImage1”).src = “english image url”;
locale = (“en);
}
export function localBm_click_1(event, $w) {
$w(”#tncEn").hide();
$w(“#tncBm”).show();
$w(“#tncCn”).hide();
$w(“#floatText”).text = “BM Text”;
$w(“#bankImage1”).src = “bm image url”;
locale = (“bm);
}
export function localCn_click_1(event, $w) {
$w(”#tncEn").hide();
$w(“#tncBm”).hide();
$w(“#tncCn”).show();
$w(“#floatText”).text = “chinese text”;
$w(“#bankImage1”).src = “chinese image url”;
locale = (“cn”);
}
$w.onReady(function () {
if (localeEn === null ) (localeCn === null) (localeBm === null); {
$w(“#tncEn”).show();
$w(“#tncBm”).hide();
$w(“#tncCn”).hide();
$w(“#floatText”).text = “english text”;
$w(“#bankImage1”).src = “english image url”;
locale = (“en”);
}
if (localeEn === true) {
$w(“#tncEn”).show();
$w(“#tncBm”).hide();
$w(“#tncCn”).hide();
$w(“#floatText”).text = “en text”;
$w(“#bankImage1”).src = “english image url”;
locale = (“en”);
}
if (localeBm === true) {
$w(“#tncEn”).hide();
$w(“#tncBm”).show();
$w(“#tncCn”).hide();
$w(“#floatText”).text = “bm text”;
$w(“#bankImage1”).src = “bm image url”;
locale = (“bm”);
}
if (localeCn === true) {
$w(“#tncEn”).hide();
$w(“#tncBm”).hide();
$w(“#tncCn”).show();
$w(“#floatText”).text = “chinese text”;
$w(“#bankImage1”).src = “chinese image url”;
locale = (“cn”)
}
//
//TODO: write your page related code here…
});
and i was doing it on Site code not at the Page code .