Hello,
I have a dynamic page which should be multilingual. As this feature is not supported, I am adding the update via Wix Code (see the code below).
The change of language works fine, but to change the text I use getCurrentItemIndex which always returns 0, for every item in the database. So when I come from the index page, the rest of the items looks good, but a title always shows the first item in the table (though in the correct language).
import wixData from ‘wix-data’;
import wixWindow from ‘wix-window’;
$w.onReady(function () {
//TODO: write your page related code here…
$w(“#dynamicDataset”).onReady( () => {
console.log(“the dataset is ready”);
update_items();
});
$w(“#dynamicDataset”).onCurrentIndexChanged( (index) => {
console.log(“the item changed”);
update_items();
});
});
function update_items () {
const current_item = $w(“#dynamicDataset”).getCurrentItemIndex();
let language = wixWindow.multilingual.currentLanguage;
let title_text;
console.log(current_item);
wixData.query(“Eventos”).find().
then( (results) => {
if(language === “es”){
title_text = results.items[current_item].title_es;
} else if (language === “de”) {
title_text = results.items[current_item].title_de;
} else {
title_text = results.items[current_item].title;
}
$w(“#text85”).text = title_text;
});
}
Best regards,
Hernan