Switch language in string constants

0
Hi, I am working on a language selection in a app. And it’s comfortable for switching the labels of the frontend widgets. But I have defined several string constants and using it for changing some text fields in a pushed app. My use case to easily adapt several descriptions in a pushed application. But I don’t know how to realize the language selection for these string variables. Do have an idea or a best practice solution for this case? Thanks and regards Ingo
asked
2 answers
0

Hi Ingo,

 

Constants are fixed and don't change based on the langauge of the user. They ‘live’ in  as environment variables on the server level, and not in a user context. 

 

I think the best solution is to build this custom, by creating an entity named something like ‘Translations’ with three attributes: 

- Locale (enumeration with languages you want to support)

- Key (enumeration with values for all the fields you want translated)

- TranslatedText (string)

 

You can then generate the objects and the translations, or make them managable from within the application. Or you can make a excel upload for it.

 

Then when you need a translation do a retrieve on the Translations table, with the locale that matches the user language, the key and display the translated text.

 

Hope this helps.

answered
0

I hope this write up is still relevant to your usecase: https://medium.com/p/ae6c7ec35dee

answered