在 Wix Multilingual
請問2個多狀態方塊EN.ZH,設定好了但沒成功,
可以幫我看看是哪邊該修正嗎?
網址https://www.cyid.online/en/departmenthighlights
最下方的表格要做中英文轉
語法:
import wixWindow from 'wix-window';
const Lang = ['EN'];
$w.onReady(function () {
let lang = wixWindow.multilingual.currentLanguage;
if(Lang.includes(lang)){
$w('#statebox8').changeState('EN'); }
let state = $w('#statebox8').state;
let foundState = state.filter((state)=>{state.id === lang});
if(foundState.length>0){
$w('#statebox8').changeState(foundState[0]); }
else{
$w('#statebox8').changeState('ZH');
}
請更改多狀態方塊的ID為小寫(lower case), 及更改以下所示的語言代號就可以了:
import wixWindow from 'wix-window'; const Lang = ['第二語言']; $w.onReady(function () { let lang = wixWindow.multilingual.currentLanguage; if(Lang.includes(lang)){ $w('#statebox8').changeState('第二語言'); } let states = $w('#statebox8').states; let foundStates = states.filter((state)=>{state.id === lang}); if(foundStates.length>0){ $w('#statebox8').changeState(foundStates[0]); } else{ $w('#statebox8').changeState('第一語言'); } });
#多狀態方塊 #多國語言