10
 Followers
69
 Likes

Persist locale IN SERVER SIDE between mobile calls to server actions

Frontend
Implemented
on 30 Nov 2020
Platform Server 11.10.1

Outsystems don't preserve, by now, session variables in server side, when you call from mobile apps, between calls.

This is how it works, and it is "reasonable", but it does preserve some data such as UserId or TenantId (when you do a SwitchTenant) between mobile calls to a server actions for the correct behavior of platform.

The problem:

If you have a multilingual mobile app, the translations in client side can be resolved with: “Multilingual Mobile Component”. 

But when you have core modules, with server static tables, server process, server sends emails, etc...  What's up with the locale? 

Currently, the locale, in each call from mobile call is set in the platform default local (for example, en-US). If the user want to retrieve the translation of static tables in his language (for example French), or send emails using the translation resources in french, need to set the locale all the time en each server action that is called by a mobile app.

This is also a problem, when you use an aggregate in movile app in screen, and join with an static table, because you can not set locale in server side before aggregate execute, and locale translations allways are retrived in default Platform language.

Example:

I attach a solution with a mobile app and a core services with an static tables of colors, translated with resources in French, Spanish, and English. 

We have two server actions, one that returns colors, and the other one that setlocale to french and return colors...

We have a mobile app with two buttons, Button "getcolors", that returns the colors without set locale. If you click first, the colors are returned in US (the default locale of platform), and are printed.

If you click the second button, locale is setting in french and colors returned in french.

If you click second button (and locale is setted), and after you click first button, colors should be returned in french (as the web applications do). But you can see that are returned in english, so locale don't persist between server calls...


The second part of mobile screen calle "colors from agregate", is performing an aggregate agains static server table, and, as you can see, retrieves the result in default locale (en-US).


This has been explain into support case 2233103, and, we have confirm with Outsystems that there is no workarround once time only, you need to set locale each time you call to a server action.


Solution:

If you set locale with SetCurrentLocale action in server side, it sounds reasonable that the following calls from this user to servers actions (in that session) you want to use the same language (at least until you make another SetCurrentLocale), so Locale should be also persisted in server side (like tenantId or UserId), between movile calls.

 1568656146117TestLocalevRunning16September2019174722.zip
Created on 19 Sep 2019
Comments (11)

The Tenant and the User IDs are stored in the Site Properties, something different than Session Variables, are you sure that you are talking about the same concept?

Why don't you store the locale in the local storage? Then you are all set to keep it, that's the way that it should be in mobile development from my perspective.

Hi William!

Let me explain you carefully about the problem, because it's not easy to understant... Local storage does not work for this. If you read carefully the description, what we try to avoid is SetCurrentLoale in SERVER ACTIONS again and again, when we call from mobile apps...

Imagine you have this:

If you call from mobile app to SERVER ACTION 1, and set locale to fr-FR, then the static entity data is retrieved in french (if you have translations to french in multilingual resources). But when, after the call to server action 1, you call to server action 2, in which language is retrieved the static entity data? 

If SetLocale would persist between calls (like TenantId does), data would retrieved in french, but currently this don't work this way, we need to SetCurrentLocale, again, in server action 2. If not, data is retreived in default platform language.

We really need that the locale language persist between server action calls. The standar way would be set it into login user action, or when the user changes the language that want his application (for the server side), and not need pass a parameter in each server action, and SetCurrentLocale in each server action. All this has been confirmed with Outsystems support and R&D Team that currently is no chance to do in other way, which is a big problem. 


As you see, save in locale storage the locale language don't work for this purpose in anyway, far as I know. We talking about server side language.

And, about TenantId, a detail: although it appears as if it were a site property, really goes by user (so It should be placed into session properties). And, the important thing, if you make a TenantSwitch in server action 1, when you call to Server Action 2 TenantId is already set it (set it for each user, all users can set his tenantId,  for that reason I say it's more like a session property), you don't need set it again. So, what we want is locale language works like tenantId


I hope to have explained myself propertly.


Regards,
Carlos.


Changed the category to Frontend and the status to

On our radar


Hi Carlos,

You are right, this is indeed an issue.

The new client variables (that in the next server version will be able to be read in screen aggregates and data actions) might be a workaround for this, but not completely. I'm changing this idea to on our radar so we can keep an eye on it.

Thanks,
Tiago Simões

Would be really very very useful! We have a big factory with huge web and mobile app (that share core services) and we had to set hundreds of times locale (and changes aggregates to fech data) to mobile app works properly with multilingual :-\

So It's really great news that is on your radar now! :-)


Carlos

Great, would make multilingual mobile development much easier! 

Great idea! 

Nice!

good idea!!!

Changed the status to
Working on it
expected delivery in Q4 2020


Hi Carlos,

I'm glad to let you know that in 11.10 we'll make available a technical preview feature that will make mobile and reactive apps have a much more integrated way of being translated (similar to traditional web). 

With that we're also making sure locale is persisted across requests.

Cheers,
Tiago Simões

Great! Can't wait for it! :D

Changed the status to
Implemented
on 30 Nov 2020


Hi Carlos,

Since 11.10 it's now possible to turn on the "Technical Preview - Multilingual Reactive Web and Mobile Apps" feature in Lifetime. With this, locale is kept between client and server calls. Now it's a great time to use this feature and give feedback on it. 

Thank you very much for your idea. Keep them coming.

Cheers,
Tiago Simões

PS: There is also an how-to explaining how to convert mobile translations based on the old forge multilingual component to the new integrated translations.  

views
964
Followers
10