I have a website in English and Spanish. I would like to change the query depending the language chosen to feed the repeater’s button " ButtonSubCategoryArt ".
With my below code it is not working. Only the Spanish query (last) is set up.
What I made wrong?
Thank you for your help.
Best Regards,
Domivax
$w.onReady(function () {
if (wixWindow.multilingual.currentLanguage === "en") {
$w("#ButtonArt").label = "Art EN";
//QUERY TO GET DATA - ART
wixData.query("Sub-Category-002")
.eq("published", true)
.eq("category", "7a45da29-2181-41c5-97fd-72749202a982")
.limit(40)
.ascending("subCategoryEn")
.find()
.then(res => {
$w('#RepeaterSubCategoryArt').data = res.items;
});
$w('#RepeaterSubCategoryArt').onItemReady( ($w, items, index) => {
$w("#ButtonSubCategoryArt").label = items.subCategoryEn;
});
}
else if (wixWindow.multilingual.currentLanguage === "es") {
$w("#ButtonArt").label = "Art ES";
//QUERY TO GET DATA - ART
wixData.query("Sub-Category-002")
.eq("published", true)
.eq("category", "7a45da29-2181-41c5-97fd-72749202a982")
.limit(40)
.ascending("subCategoryEs")
.find()
.then(res => {
$w('#RepeaterSubCategoryArt').data = res.items;
});
$w('#RepeaterSubCategoryArt').onItemReady( ($w, items, index) => {
$w("#ButtonSubCategoryArt").label = items.subCategoryEs;
});
}
});
maybe try to console.log your wixWindow.multilingual.currentLanguage value when you change the site’s language to english and then you can understand what went wrong.
did you enable wix multilanguage in your editor settings?