Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Locale change and JFaceResources
Locale change and JFaceResources [message #1833763] Fri, 23 October 2020 12:43 Go to next message
Peter Hermsdorf is currently offline Peter HermsdorfFriend
Messages: 44
Registered: August 2011
Member
Hi,

we have a RCP Application based on Eclipse Mars.1 and we are in the process of supporting multiple languages.

We use the "new eclipse localization" described by Dirk Fauth and Tom Schindl here http://blog.vogella.com/2013/05/22/eclipse-internationalization-part-24-new-message-extension-by-dirk-fauth-and-tom-schindl/

Before the Workbench shows up we use a Splash Screen to provide a login form. After Login we switch the Application language to the preffered language of the user, which can be different from the system language.
In order to get that working we are starting our product with
-Declipse.registry.MultiLanguage=true


We do the locale switch with something like
Locale.setDefault(userLocale);
IEclipseContext context.set(TranslationService.LOCALE, userLocale);


Overall this works as expected (Views and Editors are in english etc. ), but e.g. in the about Dialog (and probably in other parts of Eclipse) the Buttons "Installation Details" are still in the system language (german in my case) and not in the user language.

Root cause from my point of view is the class JFaceResources where the translations are obtained by
public static String getString(String key) {

which get's them from a static ResourceBundle which get's initialized very early
/**
	 * The JFace resource bundle; eagerly initialized.
	 */
	private static final ResourceBundle bundle = ResourceBundle
			.getBundle("org.eclipse.jface.messages"); //$NON-NLS-1$


Is there anything I've missed or I can do to get these JFace Strings also in the correct language?
Is this somehow changed/fixed in newer Eclipse versions?

Thanks for any hints!

Best Regards,
Peter



Re: Locale change and JFaceResources [message #1834180 is a reply to message #1833763] Wed, 04 November 2020 11:33 Go to previous messageGo to next message
Peter Hermsdorf is currently offline Peter HermsdorfFriend
Messages: 44
Registered: August 2011
Member
Should I raise a bug for this?

Bye Peter
Re: Locale change and JFaceResources [message #1837006 is a reply to message #1834180] Wed, 20 January 2021 20:34 Go to previous messageGo to next message
Wim Jongman is currently offline Wim JongmanFriend
Messages: 493
Registered: July 2009
Senior Member

Hi Peter,

The language switch you use will only work for your application. Eclipse itself does not use it. For anything coming from Eclipse (about, p2, marketplace, etc..) you have to include the language packs for each language you support.



Cheers,

Wim
Re: Locale change and JFaceResources [message #1847920 is a reply to message #1837006] Fri, 12 November 2021 15:13 Go to previous messageGo to next message
Peter Hermsdorf is currently offline Peter HermsdorfFriend
Messages: 44
Registered: August 2011
Member
Hi Wim,

sorry for being that late with my reply.

The missing language packs isn't the problem. If the language is not changed after product startup everything works fine.
But when changing the user language programmatically, eg. after user login the way JFace in RCP resolves/handles localizable string does not work for me.

The problem is: JFace resolves all of its keys to static strings with a static resource bundle (This is different in the RAP implementation of JFace which respect's the "current" locale of the user while resolving the messages - thus it works there).
e.g. see org.eclipse.jface.dialogs.IDialogConstants.OK_LABEL which is used by multiple platform dialogs. (eg. the mentioned About Dialog) IDialogConstants is an interface and once the Strings are resolved they are effectively static.
This makes Eclipse strings appear in the wrong language.

The "new eclipse localization" mechanism is described by Dirk Fauth in a very good blog series: http://blog.vogella.com/2013/05/22/eclipse-internationalization-part-24-new-message-extension-by-dirk-fauth-and-tom-schindl/

So it seems to me that the JFace Labels just haven't been touched by this change.

Is that something I can create a Bug for? The solution could be similar like it's been solved in the JFace RAP implementation....

Thanks for any comments.

Bye Peter

Re: Locale change and JFaceResources [message #1851457 is a reply to message #1847920] Wed, 06 April 2022 08:57 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Sorry for being that late in the discussion. I didn't check the platform forum for a long time.

Actually the issue can't be solved that easily. The "new eclipse localization" mechanism is based on Eclipse 4 and injection. JFace should also work outside such an environment, even in plain Java with SWT/JFace for example. So it would not be possible to integrate that mechanism in JFace itself. The only way would be to add a mechanism that is able to override labels in the consumer of the JFace API. But I think there are many places in Eclipse that would not be able to use the new localization mechanism because of the dependencies.
Re: Locale change and JFaceResources [message #1851506 is a reply to message #1851457] Thu, 07 April 2022 05:51 Go to previous messageGo to next message
Peter Hermsdorf is currently offline Peter HermsdorfFriend
Messages: 44
Registered: August 2011
Member
That's bad news. For now we can live with that because this problem only affects some basic workbench parts (like the About Dialog) but some kind of solution would be good.

Dirk, thanks anyway for your comment.

Bye Peter
Re: Locale change and JFaceResources [message #1851683 is a reply to message #1851506] Tue, 12 April 2022 11:51 Go to previous messageGo to next message
Christopher Smith is currently offline Christopher SmithFriend
Messages: 1
Registered: April 2022
Junior Member
It is a pity that there is no solution for this case yet. I have a similar problem, so I would be grateful if you could let me know when this issue can be solved.
Re: Locale change and JFaceResources [message #1856214 is a reply to message #1851683] Mon, 28 November 2022 09:30 Go to previous message
Marco Lopes is currently offline Marco LopesFriend
Messages: 61
Registered: September 2010
Member
My solution was to implement my Custom Dialog... you can personalize the TITLE and BUTTON labels

https://github.com/marcolopes/dma/tree/master/org.dma.eclipse/src/org/dma/eclipse/jface/dialogs/message
Previous Topic:SBOM for eclipse products
Next Topic:Is it possible to use System.Logger instead of org.eclipse.core.runtime.ILog?
Goto Forum:
  


Current Time: Wed Apr 24 14:17:01 GMT 2024

Powered by FUDForum. Page generated in 0.03164 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top