Update a variable based on the user's browser language

Hello,

I’m interested in creating a multilingual platform and would like to have the language displayed based on the user’s browser settings by default.

How can I accomplish this?

My initial thought is to use a variable array containing French and English, and then set up the variable based on the user’s browser language preference. However, I’m not sure about the implementation details.

Could you provide guidance on how to achieve this?

Thank you.

You probably would need to use custom JS to get the browser part. I’m attaching an article I found by searching Google. For the setting language part, you can use the Workflow action for this, there should be something like “Change / set language”.

Hi @Davy :wave:

Do you need an automatic translation of your app or do you have the text in different languages accessible in a DB or via API?

If the latter, it should be doable fairly easily without resorting to code. Here’s how you can add languages to your WeWeb app.

If you have several languages active on a page, every text element will come with several inputs:

The language displayed on the published app will depend on the user’s browser settings.

Does that help?

1 Like

Does it really? I know of an app that is built in WeWeb and it just forces Spanish on me every time :open_mouth: They might have done this on purpose via a workflow tho :slight_smile:

Indeed that seems super interesting and seems it’s solving all of my issues.

Can you tell me more how does it work for SEO with this methodology?

Does each page get to be referrenced on google by language?

@Broberto, I think you are right. My Weweb app doesn’t display the language based on Browser’s current language anymore. In the past it worked, but not anymore. Now always displays the default language no matter what browser’s language is. So I must get the window.navigator.language with javascript and then change Weweb’s language manually with the Change Language workflow action.

1 Like