[Multilingual Component] Change language of default exception handlers

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

Basic info

Using OutSystems 11.7.2 as platform at the moment. Trying to figure it out for our Mobile application but should do the same in our Reactive application.


Actual problem

Trying to find out how to translate default exception handlers. For example; when a user does not login with the right credentials the user is shown "Invalid username or password" (as seen in the screenshot below). In the documentation of this module I cannot find how to do translations of this. Also in the screenshots below you can see I did start by using the AddTranslationsFromResource method. Are there any keys available for the global handlers or can anyone point me in the direction on how to do this?


Bart Nooijens wrote:

Basic info

Using OutSystems 11.7.2 as platform at the moment. Trying to figure it out for our Mobile application but should do the same in our Reactive application.


Actual problem

Trying to find out how to translate default exception handlers. For example; when a user does not login with the right credentials the user is shown "Invalid username or password" (as seen in the screenshot below). In the documentation of this module I cannot find how to do translations of this. Also in the screenshots below you can see I did start by using the AddTranslationsFromResource method. Are there any keys available for the global handlers or can anyone point me in the direction on how to do this?


Hi Bart,


 where do you have entry for your locale in json file like below for "Invalid username or password".


Salman Ansari wrote:


Hi Bart,


 where do you have entry for your locale in json file like below for "Invalid username or password".



Hi Salman,

I tried to do it like this but that is not working:

I guess it is because it is calling this handler but that is actually the problem I have. I am not sure on how to call the translations in such handlers.

And to show the translations file is being called: Below the input you can see "Verplicht veld" as I also mentioned in the json.

Hi Bart,


Do you use GetTranslation function from Multilingual Component on the message field of the message component?


Similar to this:


Let me know if this helps.


Patrícia

Patrícia Glória Ferreira wrote:


Hi Bart,


Do you use GetTranslation function from Multilingual Component on the message field of the message component?


Similar to this:


Let me know if this helps.


Patrícia



Hi Patricia,

I know I could use the GetTranslation function for translating several things but I think my usecase is a bit different.

This "invalid username or password." message is being generated by the default exception handler in the login flow. Depending on what you do wrong the information is filled in differently (See screenshot below with the "Too many failed login attempts. Please try again in 60 minutes"). I actually want to have this functionality to stay like this but just want to change the messages from English to Dutch.



Oh sorry misunderstood your problem.


Where do you send that exception? What I'm doing is the action that sends the exception, sends in the exception message the key of the translation we want to show.


Also, one question, what do you have in the message field in the message component?

Patrícia Glória Ferreira wrote:

Oh sorry misunderstood your problem.


Where do you send that exception? What I'm doing is the action that sends the exception, sends in the exception message the key of the translation we want to show.


Also, one question, what do you have in the message field in the message component?

Hi Patricia,

This is the default exception that is called within the login client action in the login screen and is implemented by default.

I am not sure what you mean with "What I'm doing is the action that sends the exception, sends in the exception message the key of the translation we want to show." Do you have an example?

I guess you mean the message below? This is just the default message in the handler and is filled differently depending on what you are doing on the screen.

Solution

Hi Bart,

On that handler you can check if the message is any of the following:

  • "Too many failed login attempts. Please try again in 60 minutes."
  • "Too many failed login attempts. Please try again in a few minutes."
  • "Invalid username or password."

And use the GetTranslation() function for all of these.

I'll also add an issue on our side to translate those to dutch in the Users module.

Cheers,
Tiago Simões

Solution

Tiago Simões wrote:

Hi Bart,

On that handler you can check if the message is any of the following:

  • "Too many failed login attempts. Please try again in 60 minutes."
  • "Too many failed login attempts. Please try again in a few minutes."
  • "Invalid username or password."

And use the GetTranslation() function for all of these.

I'll also add an issue on our side to translate those to dutch in the Users module.

Cheers,
Tiago Simões

Hi Tiago,


Seems like this is working. Thanks :)


I attached a few screenshots.