Community
Participate
Working Groups
With the following question on stackoverflow, I started looking into the possiblities on using a custom TranslationService implementation. http://stackoverflow.com/questions/21776496/eclipse-rcp-getting-resourcebundles-using-custom-resourcebundle-control IMHO the code to retrieve the bundle now also exists in the ResourceBundleHelper I contributed for the new message extension. So the logic could be reused. The getResourceString() method is something that every implementation will need, as it deals with the leading % which is a pre-requisite for translations in the application model. Therefore I would transfer it to the TranslationService with protected visibility, so custom TranslationService implementations could simply use it instead of copying the code. As a third fact I would like to get the BundleLocalization injected rather than getting it directly via ServicesActivator. With these modifications it would be simply to create a custom TranslationService. And it would also be enable people to easily use ResourceBundles that are retrieved from different locations than the OSGi ResourceBundle, e.g. as use case on stackoverflow, retrieving the ResourceBundle from another server by using a different ResourceBundle.Control. I asked on the e4 mailing list about opinions on that, but there was no response yet. Having the API freeze of Luna M6 in mind, I wanted to create the ticket and provide a patch via Gerrit.
See https://git.eclipse.org/r/#/c/22159/
Released as http://git.eclipse.org/c/platform/eclipse.platform.runtime.git/commit/?id=fd207f947353ca7c3e6e80fe7bf7d7bcf38d47f2 Thanks Dirk. PW
Dirk, can you confirm and then resolve the bug? PW
Hi Paul, I pulled the current origin/master and tested with my examples on GitHub. Everything seems to work fine. If you want to do some checks too, here is the link to my GitHub repo: https://github.com/fipro78 But I still get the following warning: IMessageFactoryService.getMessageInstance(Locale, Class<M>, ResourceBundleProvider) has non-API parameter type ResourceBundleProvider Checking the MANIFEST in org.eclipse.e4.core.services I see that the exported package org.eclipse.e4.core.services.translation is configured as x-internal:=true Is that intended? I would have thought that the core.services.translation package should have the same visibility than core.services.nls
+1 on making the translation package API with Luna
(In reply to Thomas Schindl from comment #5) > +1 on making the translation package API with Luna I like the current policy to release only something as API which has been around for a while, the translation service feels a bit to new for me to be released as API for Luna. Also it look like Dirk is still actively improving it, maybe better to wait for Luna+1?
You are mixing things up - Translation-Service is available since the inception of Eclipse 4! The new stuff is the NLS-Package!
(In reply to Thomas Schindl from comment #7) > You are mixing things up - Translation-Service is available since the > inception of Eclipse 4! The new stuff is the NLS-Package! Thanks for the clarification but didn't we just change the Translation Service in this bug? I did not not at the code change, so I might be wrong.
we modified it but in an API compliant way - the API of the service has not been modified but we moved some code from internal to external so that people can reuse things when implementing a custom version
what refactored is the default implementation we are providing!
(In reply to Thomas Schindl from comment #10) > what refactored is the default implementation we are providing! Thanks again for the clarification, +1 for the API release in this case from me too.
In Build id: N20140219-2000 I see the following error in the Error Log java.lang.StringIndexOutOfBoundsException: String index out of range: -1 at java.lang.String.substring(String.java:1918) at org.eclipse.e4.core.internal.services.ResourceBundleHelper.getResourceBundleForUri(ResourceBundleHelper.java:132) at org.eclipse.e4.core.internal.services.BundleTranslationProvider.translate(BundleTranslationProvider.java:29) at org.eclipse.e4.ui.model.LocalizationHelper.getLocalized(LocalizationHelper.java:134) at org.eclipse.ui.internal.quickaccess.ViewElement.getLabel(ViewElement.java:100) at org.eclipse.ui.internal.quickaccess.QuickAccessElement.match(QuickAccessElement.java:92) at org.eclipse.ui.internal.quickaccess.QuickAccessContents.computeMatchingEntries(QuickAccessContents.java:341) at org.eclipse.ui.internal.quickaccess.QuickAccessContents.refresh(QuickAccessContents.java:128) at org.eclipse.ui.internal.quickaccess.QuickAccessContents$2.modifyText(QuickAccessContents.java:522) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:179) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4423) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1388) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3771) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3391) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1122) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1006) at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:147) at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:620) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:571) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:125) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:133) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:103) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:374) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:228) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603) at org.eclipse.equinox.launcher.Main.run(Main.java:1462) at org.eclipse.equinox.launcher.Main.main(Main.java:1438)
The reason for this is an invalid contributorURI, that is technically valid. See Bug 428728 It appears when trying to enter values in the Quick Access. As in the ModelProcessor the contributorURI is set to "bundleclass://org.eclipse.e4.tools.emf.liveeditor" without specifying a class, the String transformation fails with that exception. I aggree that this should be made more fail safe and the error should be logged. After response from Paul about the API question I will create an additional patch to solve the issues reported.
(In reply to Thomas Schindl from comment #5) > +1 on making the translation package API with Luna OK, if you think that's fine. You can remove the x-internal (mark that package as visible to downstream plugins if using the tool). Then we need to make sure that this kind of error simply is logged and doesn't interfere with any other attribute. PW
See https://git.eclipse.org/r/#/c/22365/
(In reply to Dirk Fauth from comment #15) > See https://git.eclipse.org/r/#/c/22365/ Released as http://git.eclipse.org/c/platform/eclipse.platform.runtime.git/commit/?id=e0f108c75adb292bbccb383c9abb6e3c5e6dd629 PW
I fetched origin/master, tested the two translation examples and executed the szenario Lars described. In all cases everything looks fine. Also the API warning is gone. Therefore I mark this ticket as resolved as it was requested in comment 3.
By inspection in 4.4.0.I20140303-2000 PW
Downloaded and installed 4.4.0.I20140303-2000 Imported my projects from GitHub that are making use of the new features. Started the sample applications without any further modifications, and everything works as expected.