How to Translate Dynamic JSON Keys using the Multilingual Web Component

Greetings Folks,

I have a JSON string array in one of my action something like this:

[{

               "Name": "Company Name",
               "Label" : "New Name:",
               "Value" : "Kepler"   

}]

The object in the JSON array can be dynamic, overall I have 500+ possible objects which can exist in the JSON array. We store the JSON in Entity as a Text & then populate it to render on UI.

I am using this JSON to show on UI & I have a requirement to Translate the Label accordingly. Based on selected language on the portal the Label on UI will be Translated.

How can I map these Strings in Multilingual File or Prepare a Translation for this?


Thanks in Advance,

Assif





Assif, you would already know that OutSystems multilingual support is available for static entities. If that is an option in your case, there are couple of approaches you could take. All these approaches would require you to restructure your database and change the way you pull information from database.

1. Storing the label part of the string in static entity and each json record as a separate row in normal entity referencing the static entity record. This would help you to benefit from the out of the box multilingual feature.

2. Store translations in database , each json record as a row in normal entity, and then have the json entity reference each language column from translations entity.

Hope this helps!

Junaid


Hi Juanid,

Thank you for the reply & I appreciate your thoughts on the same.

Yes, I know & already had acquired the same approach in some of my other use cases.

At least in the above case, I cannot go with Static but yes with the entity approach which is not feasible or the best way to go for the same. I will elaborate on why...


I have a generic module which I use to trace the changes made on any record of any entity in the DB. For ex, I changed the User-Details so unless it is approved the changes I store in a JSON in an entity & then this generic module read the JSON & return the changelog of the respective fields changed.

Now it is working like a charm but I got stuck when I try to Translate the labels. I refer to the Labels of Attributes of an entity.  
Well now going for an entity or static approach: I have to maintain those every time I change my Entities... Which is something I am not satisfied to go with :)


Hope u get my point.
Assif