[ https://issues.apache.org/jira/browse/DELTASPIKE-1415?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Syed Shah updated DELTASPIKE-1415: ---------------------------------- Description: It'd be great to map enum constants to internationalization messages in a cleaner way. The use case is so an enum can be used to define something which users will see: - The status or state response for an action, represented by an enum. - The names for enum values such as togglable features, or types of a particular action that can be taken. - Where users must specify a specific item from a list. The simplest examples would be to return the localized status message of an action: If a method can return the statuses: _ENTITY_NOT_FOUND_, _ENTRY_NOT_CHANGED_, _ENTRY_ADDED_, _ENTRY_UPDATED_. *src/main/java/resources/org/example/myapp/EnumMessages.properties* {code} org.example.app.EntryUpdateStatus.ENTITY_NOT_FOUND=No data is being stored on this entity. org.example.app.EntryUpdateStatus.ENTRY_NOT_CHANGED=No change has resulted from your action. org.example.app.EntryUpdateStatus.ENTRY_ADDED=You've now explicitly set that value. org.example.app.EntryUpdateStatus.ENTRY_UPDATED=You've changed the setting. {code} An alternative example may be when naming toggles or some kind of categories. Suppose an enum with the values _COMMON_, _UNCOMMON_, _RARE_, _LEGENDARY_. *src/main/java/resources/org/example/myapp/EnumMessages.properties* {code} org.example.app.Rarity.COMMON=Vanlig org.example.app.Rarity.UNCOMMON=Uvanlig org.example.app.Rarity.RARE=Skjelden org.example.app.Rarity.LEGENDARY=Legendarisk {code} Then when using the desired _MessageBundle_, references of an _Enum_ data type can instead be looked up against the _EnumMessages.properties_ file, and if not found, fall back to the original _toString()_ logic. was: It'd be great to map enum constants to internationalization messages in a cleaner way. The use case is so an enum can be used to define something which users will see: - The status or state response for an action, represented by an enum. - The names for enum values such as togglable features, or types of a particular action that can be taken. - Where users must specify a specific item from a list. The simplest examples would be to return the localized status message of an action: If a method can return the statuses: _ENTITY_NOT_FOUND_, _ENTRY_NOT_CHANGED_, _ENTRY_ADDED_, _ENTRY_UPDATED_. *src/main/java/resources/org/example/myapp/EnumMessages.properties* {code} org.example.app.EntryUpdateStatus.ENTITY_NOT_FOUND=No data is being stored on this entity. org.example.app.EntryUpdateStatus.ENTRY_NOT_CHANGED=No change has resulted from your action. org.example.app.EntryUpdateStatus.ENTRY_ADDED=You've now explicitly set that value. org.example.app.EntryUpdateStatus.ENTRY_UPDATED=You've changed the setting. {code} An alternative example may be when naming toggles or some kind of categories. Suppose an enum with the values `COMMON`, `UNCOMMON`, `RARE`, `LEGENDARY`. *src/main/java/resources/org/example/myapp/EnumMessages.properties* {code} org.example.app.Rarity.COMMON=Vanlig org.example.app.Rarity.UNCOMMON=Uvanlig org.example.app.Rarity.RARE=Skjelden org.example.app.Rarity.LEGENDARY=Legendarisk {code} Then when using the desired _MessageBundle_, references of an _Enum_ data type can instead be looked up against the _EnumMessages.properties_ file, and if not found, fall back to the original _toString()_ logic. > Enum Constant Internationalization > ---------------------------------- > > Key: DELTASPIKE-1415 > URL: https://issues.apache.org/jira/browse/DELTASPIKE-1415 > Project: DeltaSpike > Issue Type: Improvement > Security Level: public(Regular issues) > Components: I18n-Module > Reporter: Syed Shah > Priority: Minor > > It'd be great to map enum constants to internationalization messages in a > cleaner way. > The use case is so an enum can be used to define something which users will > see: > - The status or state response for an action, represented by an enum. > - The names for enum values such as togglable features, or types of a > particular action that can be taken. > - Where users must specify a specific item from a list. > The simplest examples would be to return the localized status message of an > action: > If a method can return the statuses: _ENTITY_NOT_FOUND_, _ENTRY_NOT_CHANGED_, > _ENTRY_ADDED_, _ENTRY_UPDATED_. > *src/main/java/resources/org/example/myapp/EnumMessages.properties* > {code} > org.example.app.EntryUpdateStatus.ENTITY_NOT_FOUND=No data is being stored on > this entity. > org.example.app.EntryUpdateStatus.ENTRY_NOT_CHANGED=No change has resulted > from your action. > org.example.app.EntryUpdateStatus.ENTRY_ADDED=You've now explicitly set that > value. > org.example.app.EntryUpdateStatus.ENTRY_UPDATED=You've changed the setting. > {code} > An alternative example may be when naming toggles or some kind of categories. > Suppose an enum with the values _COMMON_, _UNCOMMON_, _RARE_, _LEGENDARY_. > *src/main/java/resources/org/example/myapp/EnumMessages.properties* > {code} > org.example.app.Rarity.COMMON=Vanlig > org.example.app.Rarity.UNCOMMON=Uvanlig > org.example.app.Rarity.RARE=Skjelden > org.example.app.Rarity.LEGENDARY=Legendarisk > {code} > Then when using the desired _MessageBundle_, references of an _Enum_ data > type can instead be looked up against the _EnumMessages.properties_ file, and > if not found, fall back to the original _toString()_ logic. -- This message was sent by Atlassian Jira (v8.3.4#803005)