Dynamic Multilingual Page

Hi!

I have a multingual site, and a dynamic page that shows some data from a collection.

Most of the fields are the same in all languages, but one of those, not. I created two fields called “description_spanish” and “description_english”.

But I don’t know how to connect the text to one of those fields, depending on which language is the site.

Some help?

1 Like

Hello,

One way to do this would be to set sessions, and read the data from session to see if it is spanish or english. Then based on the session, give the text element the relevant text

let text;
 wixData.query("CollectionName").find().
 then( (results) => {  
    if(session.getItem('spanish')){
    text = results.items[0].description_spanish
} else {
  text = results.items[0].description_english;
}


}); 

$w('#text1).text = text;

Best,
Majd

I don’t understand all this syntax…

session.getItem(‘spanish’) returns True if the site is in spanish?

wixData.query(“CollectionName”).find(). and what’s this for?

Hi,

I am trying to connect the table view (in style of pricing list) with 3 different databases as I have 3 different languages on the site. Unfortunately I do not know what code to use, or in case what everything I need to change in the code above so it will serve my purpose.

Any help here be appreciated,

Thank you,

Radana

I have same problem. I want to know through wix code the current language selected in multilingual app. I dont want to enable sessions. That would be an unnecessary work

Hi Radana and Romulo,
In case you use Wix Multilingual then the following documentation specifies how to get the current language - https://www.wix.com/code/reference/wix-window.multilingual.html