WixData— Switch Language

Hi guys, i was trying to make a multi language dataset, and filter it. All’s ok, until a point, where when the user is already on the page of the item, and then decide to switch the language, the page obviously change it’s value to the selected language, but i cant make it goes to the other set of fields, where there’s the translation.
My database looks like this:

and this is what set up till now in my page code:


import wixWindow from “wix-window”;
import wixData from “wix-data”;
import wixLocation from “wix-location”;

let language = wixWindow.multilingual.currentLanguage;
let baseUrl = wixLocation.baseUrl + language;

$w.onReady( function () {
dataset1_ready();

});

export function mailtoinfo_onClick(event) {
$w(“#mailtoinfo”).link = “mailto:info@bluenliguria.com?subject=ciao”;
}

export function telcontact_onClick(event) {
$w(“#telcontact”).link = “tel:<+39-392-4878701>”;
}

export function buttonModerna_click_1(event, $w) {

wixData.query(“villa”)
.eq(“language”, language)
.eq(“title”, “MODERNA”)
.find()
.then( (results) => {
$w(“#repeater1”).data = results.items;
}
)
. catch ( (err) => {
let errorMsg = err;
});

}
export function buttonFamigliari_click(event, $w) {
wixData.query(“villa”)
.eq(“language”, language)
.eq(“title”, “FAMIGLIARE”)
.find()
.then( (results) => {
$w(“#repeater1”).data = results.items;
}
)
. catch ( (err) => {
let errorMsg = err;
});

}

export function dataset1_ready() {
$w(“#dataset1”).setFilter(wixData.filter().eq(“language”, language));

}

$w.onReady(() => {

$w(“#dataset1”).setFilter(wixData.filter().eq(“language”, language));
$w(“#dataset1”).onReady(() => {
$w(“#repeater1”).onItemReady(($item, itemData, index) => {
let descrizione = itemData.descrizioneSintetica;
var sintetica = descrizione.substr(0, 200);
$item(“#descrizioneSintetica”).text = sintetica + " … →";
});
});

});


Hope someone will help me to understand this issue…

Thank you,
Tytus.

Hey Tytus, I think I understand what you mean. I had a quick look at it. The problem seems to me to be that the language dropdown element that you can put on your page to let user select another language doesnot have an onClick or onCHange event specified. They only thing close is onMouseIn/Out.
So I would try use the onMouseOut, when triggered, compare if language has changed (so first remember it in code) by getting the current language like below and than compare it to the former (saved) language. If different, than retrieve data from db en update fields:

EDIT: if that doesn´t work, make your own dropdown and set the language and do the db-interaction on the onChange. If you search the API doc on “multi”, you get all the fuunctions you need and how they work.

let language = wixWindow.multilingual.currentLanguage; // "en"


Hi Giri, thank you, your reply made me realise i might have not been that clear, as I first of all not a code_guy and also, because many times i have thoughts, that stay in my mind, the expressions seems to be in a background state…knowing that i ve made a infograph of my problem, hopefully it will do better:


www.bluenliguria.com

I was looking many many times at the refference page, the thing is that in a way i kind of get it what shall i do, than when it comes to compose the code, my mind fall aoart as i’m not used to have that logi (even though i love the code, so i’m really getting hard to understand it, by now this is my first time asking hep, before i m proudly managed to solve all the issues, filtering and others, but this one…hmm…made me goes really angry, as i know it could be a matter of syntax or catching the right element and made him do “that thing”…)

I saw this whch made me think it might be the path…
https://www.wix.com/corvid/reference/wix-data.html#get

But i need the hooks, isn’t it? {[!^ì what are they…?..

@giri-zano Thank You for your reply