Hello to everyone.
First of all, I want to thanks, in advance, Wix (which are all those people who work there), and especially those who answer our questions on Wix-Code forum, you are doing really hard work, which is really important for us, and I really appreciate that.
About my issue. I’m trying to translate data, which is retrieved from database. Here is code:
$w.onReady(() => {
//Retrieving data from “Users” collection
wixData.query(‘Users’)
.find()
.then(res => {
function unique(array) {
return array.filter((value, index) => array.indexOf(value) === index);
}
const genders = res.items.map(users => users.gender);
const uniqueGenders = unique(genders);
const options = uniqueGenders.map(gender => {
return {
“value”: gender, “label”: gender
};
});
$w(‘#genderDropDown’).options = options;
});
});
“Gender” field has many “male” and “female” values, so when it’s retrieved from “Users”, code decreases them for Drop-Down (#genderDropDown), so it will have only one - “male”, and one - “female” options, to choose between. With your help it works perfectly.
Thing is that, I need the same page to be on several languages, and have duplicated the page, translated all of the other elements on the page, but I can’t translate Drop-Down options.
I’ve tried this:
$w(‘#genderDropDown’).options[0][“label”] = “Мужчины”;
But it doesn’t work.
console.log($w(‘#genderDropDown’).options[0][“label”]);
still returns “male” to console.
Also, thought to use hooks, but have no idea how can it be done in this case. Would be very thanksfull, for your attention, time and help!