After the user logs in, you determine the language from the country you already store in the database (for example, US -> en_US, Brazil -> pt_BR). In a microflow that runs after login, retrieve the corresponding System.Language record by its code and set it on the current user via the System.User_Language association. You can then commit the user, a client refresh is not required at this point.
Because this is a native app, simply setting the language is not enough for the UI to update everywhere. As recommended by Mendix, you should clear the cached session data and reload the app. Once the app reloads, the selected language is applied globally across all pages and components.
In a native mobile app this cannot be solved with only a server microflow, so there is no pure “sample code” that will work by itself. The language change must be triggered from a nanoflow, because clearing cached session data and reloading the app are native client actions. The correct flow is: first update the user’s Language attribute in a server microflow, then call that microflow from a nanoflow, and immediately after that clear the cached session data and reload the app. If these last two steps are not executed on the client, the UI will keep rendering with the old language.
Also make sure that the language you are setting (for example en_US, de_DE, etc.) is enabled in Project Settings -> Languages and that translations exist. Otherwise the reload will happen but the UI will still look unchanged. If this logic is currently placed in an after-login microflow or any other server-side flow, moving the reload logic into a nanoflow is required for native apps.
This should explain why “trying it” without a nanoflow does not work and why a simple code example alone is not sufficient in this case.
Thank you @Ahmet Kudu. Just made some changes and it is working now.
I have extended login nanoflow like this, is it correct?
The logic to set User_Language based on the country looks correct. However, in a native app this alone may not be sufficient. After updating the language, you typically also need to clear the cached session data and reload the app so that the UI fully re-renders with the new language.
I tried it's not working , do you have any sample code?