Line 144 does get hit indeed by the following call stack and translationContext is domainapp.dom.simple.Item$ItemGroup#KeyUser for example, and friendlyNameOfEnum is Keyuser for example. But on the UI it has no effect, KeyUser is still presented as Keyuser, although I put these lines into file translations-en.po: #: domainapp.dom.simple.Item$ItemGroup#KeyUser msgid "Key User" msgstr "Key User"
I cannot easily track down whether the value is looked up but not used then or if the lookup already fails because my Maven was not successfull in downloading all the sources needed for debugging. Will need to download the missing jars later when there is more time for it. EnumValueSemanticsProvider<T>(ValueSemanticsProviderAndFacetAbstract<T>).di splayTitleOf(Object, Localization) line: 217 TitleFacetUsingParser.title(ObjectAdapter, Localization) line: 57 TitleFacetUsingParser.title(ObjectAdapter, ObjectAdapter, Localization) line: 62 ObjectSpecificationDefault(ObjectSpecificationAbstract).getTitle(ObjectAdap ter, ObjectAdapter, Localization) line: 405 ObjectSpecificationDefault(ObjectSpecificationAbstract).getTitle(ObjectAdap ter, Localization) line: 399 DomainObjectContainerDefault.titleOf(Object) line: 91 IsisSystem.translateServicesAndEnumConstants() line: 266 IsisSystem.init() line: 144 IsisInjectModule.provideIsisSystem(DeploymentType, IsisSystemFactory, AppManifest) line: 139 NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method] NativeMethodAccessorImpl.invoke(Object, Object[]) line: 62 DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43 Method.invoke(Object, Object...) line: 497 ProviderMethod<T>.get() line: 104 InternalFactoryToProviderAdapter<T>.get(Errors, InternalContext, Dependency<?>, boolean) line: 40 ProviderToInternalFactoryAdapter$1.call(InternalContext) line: 46 InjectorImpl.callInContext(ContextualCallable<T>) line: 1031 ProviderToInternalFactoryAdapter<T>.get() line: 40 Scopes$1$1.get() line: 65 InternalFactoryToProviderAdapter<T>.get(Errors, InternalContext, Dependency<?>, boolean) line: 40 SingleFieldInjector.inject(Errors, InternalContext, Object) line: 53 MembersInjectorImpl<T>.injectMembers(T, Errors, InternalContext, boolean) line: 110 MembersInjectorImpl$1.call(InternalContext) line: 75 MembersInjectorImpl$1.call(InternalContext) line: 73 InjectorImpl.callInContext(ContextualCallable<T>) line: 1024 MembersInjectorImpl<T>.injectAndNotify(T, Errors, boolean) line: 73 MembersInjectorImpl<T>.injectMembers(T) line: 60 InjectorImpl.injectMembers(Object) line: 944 DomainApplication(IsisWicketApplication).init() line: 256 DomainApplication.init() line: 64 DomainApplication(Application).initApplication() line: 823 WicketFilter.init(boolean, FilterConfig) line: 424 WicketFilter.init(FilterConfig) line: 351 FilterHolder.initialize() line: 138 ServletHandler.initialize() line: 852 WebAppContext(ServletContextHandler).startContext() line: 298 WebAppContext.startWebapp() line: 1349 WebAppContext.startContext() line: 1342 WebAppContext(ContextHandler).doStart() line: 741 WebAppContext.doStart() line: 505 WebAppContext(AbstractLifeCycle).start() line: 68 Server(ContainerLifeCycle).start(LifeCycle) line: 132 Server.start(LifeCycle) line: 387 Server(ContainerLifeCycle).doStart() line: 114 Server(AbstractHandler).doStart() line: 61 Server.doStart() line: 354 Server(AbstractLifeCycle).start() line: 68 WebServerBootstrapper.bootstrap(Injector) line: 91 WebServer.run(String[]) line: 107 WebServer.main(String[]) line: 71 WebServer.main(String[]) line: 25 Am 29.09.15 16:40 schrieb "Dan Haywood" unter <[email protected]>: >Good stuff, nice bit of investigation. I wrote that stuff, but had >forgotten about it. > >So, if you put a breakpoint on line 144 [1], does it get hit? > >Also, it looks like if you define a title() method returning a >TranslatableString, then that will get called instead, with a slightly >different context being used for the lookup of the translation [2] > >Let me know what you find out... > >Dan > >[1] >https://github.com/apache/isis/blob/isis-1.9.0/core/metamodel/src/main/jav >a/org/apache/isis/core/metamodel/facets/object/choices/enums/EnumValueSema >nticsProvider.java#L144 >[2] >https://github.com/apache/isis/blob/isis-1.9.0/core/metamodel/src/main/jav >a/org/apache/isis/core/metamodel/facets/object/choices/enums/EnumValueSema >nticsProvider.java#L126 > > > >On 29 September 2015 at 15:34, Burbach, Matthias <[email protected]> >wrote: > >> 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 >> >> >> >> >> >>
