about locale at webpage

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.

  1. page original state is english.
  2. put a button and add some code that will change entire page text and picture to other language.
  3. click button. it changed.
  4. 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 .

Hey
First of all you need to close the strings when you set the language.

locale = ("en");

If you dont close it it will not be working. Then you have to check for the contents of the string, you can’t check if localEn equals true because you have no variable called localeEn. So maybe you should check if local === “en” instead and so on. Hope it helps.

Andreas kviby…
ah my code are locale = (“en”);

it just my misstype when copy paste…

and yesterday just tried with
if local === “en”

still same result…