Change language of anonymous user

7
Did anybody already found a way to change the language of an anonymous user? I already tried to set the language of the user via a microflow, but sadly this only works within the scope of that specific microflow. Outside that microflow the language is reset to the default language. After the login we know the user and his/her language. But for the public website we don't know the visitor and his/her language. We thought of letting the visitor choose the language for the public menu and the public forms. Not a required but it would be nice of we could determine the correct default language via the language settings of the browser.
asked
2 answers
0

Could you not solve this by setting the language you wish for anonymous users to default and of all other users to whatever you wish to set it? You could add an after create for normal users and set their language to the default you currently use.

answered
0

Yes, its possible! We had the same challenge in our project. Changing the language of the user is actually fairly easy (in a microflow simply retrieved the language you want from the database, and then assign it to the current user).

Next challenge is to refresh the client as the change will not directly be visible and you dont have direct control over this in a microflow. I think there are various ways possible:

  • API: https://apidocs.mendix.com/5/client/screen.html
  • Reload page in the same window (open a page with a URL redirect, see URL Redirector in the appstore)

We went for the second option and used deeplinks to redirect to the correct page.

answered