116
Views
5
Comments
Multiple assignments for same property
Question

In my UI I display a number of contacts fetched from a database. Each contact has a title. I want to provide a translation for each title. Since this data is dynamic, I can't use the preferred method of using the Multilingual module. So I need to translate the titles after they've been returned from the DB. I'm looking for the best way to do this. Should I use a switch statement, in which case I can't find a good example of its use. Or is a foreach better? An example here would help as well.

My data looks like this:

Data.name

Data.address

Data.title

The translations are in a json file. 

mvp_badge
MVP
Rank: #71

Hi Lorenzo,

Have a look at this HowTo Forge component that showcases some examples on how to build an App with multilingual support, one of which is an example on how to translate dynamic data that is stored in the Database.

Hope this is what you are looking for!

Regards,

Nordin

mvp_badge
MVP
Rank: #71

Hi Lorenzo,

Sorry for the late reply.

I'm not sure I fully understand your use case. As far as I understand, for this you could go with the same database model as showcased in the HowTo Forge component. It would look like this. The ContactTranslations entity allows you to provide different translations in different languages for the Title attribute for each Contact.

For more information on how this works exactly, I would highly suggest to check out this excellent Master Class on Multi-Language.

Hope this helps!

Regards,

Nordin

mvp_badge
MVP
Rank: #71

Great, I’m glad I could help!