[Multilingual Component] [Reactive] setLocale not working

Forge Component
(16)
Published on 20 May (6 days ago) by OutSystems R&D
16 votes
Published on 20 May (6 days ago) by OutSystems R&D

Hi,

I'm trying to add translations to to my reactive web app as described in the documentation of this component, however the translations do not seem to work. Upon further inspection I noticed the getLocale action always returning an empty response.

Does anyone know why the locale isn't set correctly using the setLocale action?

Some more information of my current case:
- Reactive web app
- translations for English, dutch, french and german are all kept in a different entity for each language.
- addtranslations is called in the AfterFetch action when preparing the data for the page.


Solution

Hi Glenn,


What you can try is to do this on the OnInitialize of the screen:


(And if you need this for several screens, consider encapsulating it in a global client action).

This will give you a warning, but you can safely hide it as it will only be triggered the first time you navigate to a screen and the translations were not yet loaded.

Let me know if it works.


Cheers,

Tiago Simões

Solution

Tiago Simões wrote:

Hi Glenn,


What you can try is to do this on the OnInitialize of the screen:


(And if you need this for several screens, consider encapsulating it in a global client action).

This will give you a warning, but you can safely ignore it as it will only be triggered the first time you navigate to a screen and the translations were not yet loaded.

Let me know if it works.


Cheers,

Tiago Simões

Hi Tiago, 


I found and resolved the issue with the locales but the translations still aren't working.
I've switched to AddTranslationsFromResource with a resource file for each locale and all of them have deploy to target directory now.

All text has the data-trans attribute with the keys needed for translations.

Since I didn't receive any errors I tried once more with the translation actions copied into my application itself. Now I'm receiving the following error: Check the JavaScript node 'LoadResource' of the action 'AddTranslationsFromResource'.

Any clues on what might be causing the issue?


Not sure. Is it possible that the resources are not in the correct format or with the right file encoding? You might be able to use chrome dev tools to try to understand more about the issue.

Hi Glenn,

Have you been able to sort things out?

Cheers,
Tiago Simões

Tiago Simões wrote:

Hi Glenn,

Have you been able to sort things out?

Cheers,
Tiago Simões

Hi Tiago,

No luck so far, the resource files are in exactly the same json format and type as the example of the multilanguage demo app. Maybe there's something I missed so i'll go over it once more and compare with the demo to see if anything was left out.

Glenn


Hi Glenn,

Sorry I missed this last message from you. Have you seen any error messages in the chrome dev tools?

Cheers,

Tiago Simões

Tiago Simões wrote:

Hi Glenn,

Sorry I missed this last message from you. Have you seen any error messages in the chrome dev tools?

Cheers,

Tiago Simões

Hi Tiago, 

I found the solution after taking another look at your original reply.
Seems I had used the setlocale before the addTranslations action, when i switched them it worked.

Ty for your help.

Glenn


hello,

Im trying to implement in a Reactive APP the translations but giving me this error:



Im using the last version of the component.


Best Regards,

FV

Hi Fábio,

Are you sure you are using version 2.0.3? By that error it seems you are using a previous one that was a mobile only module.

Cheers,
Tiago Simões

Tiago Simões wrote:

Hi Fábio,

Are you sure you are using version 2.0.3? By that error it seems you are using a previous one that was a mobile only module.

Cheers,
Tiago Simões

Tiago, 

Thanks for the fast reply. Yes, im using the 2.0.3 version. I download the component directly from Service Studio.


Hi Fábio,

And are the dependencies are refreshed? That looks pretty strange, I'm not being able to replicate that issue.

Cheers,
Tiago Simões

Tiago Simões wrote:

Hi Fábio,

And are the dependencies are refreshed? That looks pretty strange, I'm not being able to replicate that issue.

Cheers,
Tiago Simões

It´s ok now, i close the Service Studio, delete the references add the reference again and it works.