I’m experimenting with supporting multiple languages in Lookup type tables (e.g. LookupCustomerStatus, LookupOrderStatus, etc) where I have created a separate string field for each of the supported languages. For example: getTitleEn(), getTitleFr(), getTitleDe(), etc.
I now want to create a transient property called getTitle() on these Lookup Xxx entities that is used in all dropdowns in the UI, and it should take into account the locale of the current user and return the relevant language property on that Lookup entity. For example, when the user is logged in as English the getTitle() property should return getTitleEn(), when the user logs in under the French language, the the getTitle() method should return the getTitleFr() value and so on.
I’ve tried to inject the UserSessionSource into the entity class to have access to getLocale() inside the getTitle() method, but that causes an excaption at runtime and the application will not start.
Is there any way to achieve this or is there a better way to do this?
Thanks in advance