I found this as a hint it may exist in 1.9.0 (the version which I am
using): https://issues.apache.org/jira/browse/ISIS-1106

EnumValueSemanticsProvider:

     @Override
     protected String titleString(final Object object, final Localization
localization) {
+        final TranslationService translationService =
getDependencyInjector().lookupService(TranslationService.class);
+
         if (titleMethod != null) {
-            final TranslationService translationService =
getDependencyInjector().lookupService(TranslationService.class);
             // sadness: same as in TranslationFactory
             final String translationContext =
titleMethod.getDeclaringClass().getName() + "#" + titleMethod.getName() +
"()";
 
@@ -135,7 +137,11 @@ public class EnumValueSemanticsProvider<T extends
Enum<T>> extends ValueSemantic
             }
         }
 
-        return object.toString();
+        // simply translate the enum constant's name
+        Enum<?> objectAsEnum = (Enum<?>) object;
+        final String translationContext = object.getClass().getName() +
"#" + objectAsEnum.name();
+        final String friendlyNameOfEnum =
Enums.getFriendlyNameOf(objectAsEnum.name());
+        return translationService.translate(translationContext,
friendlyNameOfEnum);
     }



Am 29.09.15 16:29 schrieb "Dan Haywood" unter
<[email protected]>:

>Um, I'm not 100% certain this is implemented, actually.  Sorry about that.
>I'll double check this evening.
>
>If you want to raise a ticket anyway, that'll be fine.  If it turns out
>there is a way then at the very least it would still need to be
>documented...
>
>Thx
>Dan
>
>
>
>On 29 September 2015 at 15:24, Burbach, Matthias <[email protected]>
>wrote:
>
>> Hi,
>> I am trying to translate enum values like so, but it has no effect.
>>
>> package domainapp.dom.simple;
>> ...
>> public class Item implements Comparable<Item> {
>> ...
>>
>> //region > item group (property)
>>         public enum ItemGroup {
>>   KeyUser,
>>   Provider,
>>   Unit
>>         }
>>         private ItemGroup itemGroup;
>>     @javax.jdo.annotations.Column(allowsNull = "false")
>>     public ItemGroup getItemGroup() {return itemGroup;}
>>     public void setItemGroup(final ItemGroup itemGroup) {this.itemGroup
>>=
>> itemGroup;}
>>     //endregion
>> ...
>>
>> }
>>
>> file translations-en.po:
>> ...
>> #: domainapp.dom.simple.Item$ItemGroup#KeyUser
>> msgid "Key User"
>> msgstr "Key User"
>> ...
>>
>>
>> I am not sure if this feature exists at all or if am just using it
>> wrongly, there some hints out there but not very clear to me.
>>
>> Regards,
>> Matthias
>>
>>

Reply via email to