[Multilingual Component] Translations for built-in validation messages of reusable blocks in core modules

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

Hi,


I have a Reactive web application where I succesfully use the Multilingual component (in combination with translations manager component 'Mobile translations' to create a JSON translation file). In my front-end end-user module I have:
- added the JSON translations resource file from Mobile translations
- in OnApplicationReady used AddTranslationsFromResource client action, SetLocale client action and also set client variable Client.Userlocale which I use throughout the application.
- have data-trans property set for all text widgets and the JSON file includes translations for built-in validation message (located on the module)
No issues so far and all translations work.

However, in my end-user module I reference and use some reusable blocks from other (core) modules that I have created there. One of them contains a Form with dropdowns and I use the auto validation in this block to validate the Form. However, the built-in validation message like 'Required field' are not automatically translated if used in my end-user module. I have tried the following:
- added JSON translation resource file in the core module + in block.OnInitialize event used AddTranslationsFromResource + SetLocale client actions.
Unfortunately, nothing works so far to enable the translations of the built-in validation messages.

Any tips to get this to work?
I've noticed that for reusable blocks in other modules, you can use the data-trans property to translate text widgets so hopefully we can get the validation messages to work too.

Kind regards

Hi Jordy,

Validation messages like that one 'Required field' are managed automatically by the platform. So they can't be translated like your text widgets or expressions that you have on your code.

As far as I know, they are dependent on the locale. Did you try with different locales?


Kind regards,

Rui Barradas

Hi again Jordy,

I was searching a bit into this.

What you can do is to hide those default messages and create your own text / expressions widgets for these field messages so you can translate them.

Please, check this documentation.


Kind regards,

Rui Barradas

Hi,

Actually it's quite possible to translate the built-in validation messages using the following keys in your Translations resource file, for example:
- Validation.Mandatory
- Validation.Integer
- Validation.Decimal
- UpgradeRequired
- UpgradeComplete
and so on for all the built-in validation messages that are defined on the module. Forge component Mobile Translations (https://www.outsystems.com/forge/component-overview/4667/mobile-translations) generates these keys by default in an application translations resource file. Although I've adjusted this component to support Reactive web apps, I'm using that resource file in my main end-user modules for these and other translations.


My goal is also get it to work for blocks in core modules that are referenced by these end-user modules. I've tried setting the locale with SetLocale client action from Multilingual component in the OnInitiliaze or OnReady of these blocks.


@Rui: You're second suggestion about disabling the built-in validation messages will work indeed, but then you're forced to back to manual (hard-coded) validation messages. So, although it's a solution, I hope to get the above working somehow.

Kind regards