27
Views
2
Comments
Solved
Static entities in multilingual application: return default value

Dear cummunity,

I have a multilingual application and that always comes with a lot of challanges (at least for me 😅).


I have a static entity (priority) for which the values are translated to the user's locale. This works well.

Now I have also implemented an audit trail and I would like to leave a log with priority.label (a translated value). In my logs however I do not want the translated value, I want the default value. 

I know I would be able to set the locale, and then change it back, but this seems to be a little overkill? 

Is there any other way I would be able to accomplish this? I cannot imagine I am the first OS developer encountering this issue.. 


Kind regards,

Liesbeth


Solution

You could add another attribute to your static entity that you don't translate. And call it for example 'LogValue'.
Since you won't add any translations to it, it would take the default value.
And use the new attribute in your logging logic instead of the translated attribute

I was afraid for that answer and hoping for a better solution :) 

Thank you. 

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.