Issue with language when navigating to other page

I have a header where, when I click on the flag, I change the state of a Custom State “Language”. Based on this, and with conditionals, I change the language of each text I have.

The problem is that when I navigate to another page, the custom state “language” of the header is lost and the texts return to their “original” language, which means that I have to click on the flag again to keep it.

How can I do to keep the custom state when I change pages?

Which would be the best approach to work with this?

Translated with DeepL Translate: The world's most accurate translator (free version)

Hi there, @santiagopoli3… what you are describing is exactly how custom states work, meaning that a custom state that is set on a particular page is only “valid” until the page is refreshed or the user navigates to a new page.

It sounds like you need a field on the User data type in which to store a value that corresponds to a user’s language preference. So, when the user clicks on a flag, you save a value to a field on the User data type (such as Current user's language), and then you can reference that field’s value on any page or element to show the correct language. Make sense?

Hope this helps.

Best…
Mike

2 Likes

This topic was automatically closed after 70 days. New replies are no longer allowed.