Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » e(fx)clipse » Locale changes at runtime(How to handle labels in Applicatin.e4xmi ?)
Locale changes at runtime [message #1451057] Thu, 23 October 2014 09:09 Go to next message
Thomas Elskens is currently offline Thomas ElskensFriend
Messages: 159
Registered: September 2014
Location: Brussels - Belgium
Senior Member
Hello,

I'm trying out the method to change language at runtime as described here: http://tomsondev.bestsolution.at/2014/10/13/effeciently-dealing-with-translations-in-an-e4-app-with-the-help-of-java8/.

First of all, it works really great, very nice job !

But I do have one question : can I handle the labels of Application.e4xmi with this method ?

I thought at least the part labels should be manageable with
@Inject MPart part ;
//...
registry.register(part::setLabel, registry::PartNameKey) ;


But this doesn't seem to work. And of course, menus etc. couldn't be done at all like this.

If I use the standard OSGi-resource bundle, I lose the benefit of the at-runtime language change.

Any tips on how to proceed ... ?

Thomas
Re: Locale changes at runtime [message #1451069 is a reply to message #1451057] Thu, 23 October 2014 09:25 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
In theory this should work what I don't understand is why you loose
runtime locale change when you use OSGi-Resource Bundle. If you
application model is internalized it should simply work.

If you provide a demo application I can run, I can try to see what's
wrong and what needs to be fixed.

Tom

On 23.10.14 11:09, Thomas Elskens wrote:
> Hello,
>
> I'm trying out the method to change language at runtime as described
> here:
> http://tomsondev.bestsolution.at/2014/10/13/effeciently-dealing-with-translations-in-an-e4-app-with-the-help-of-java8/.
>
> First of all, it works really great, very nice job !
>
> But I do have one question : can I handle the labels of
> Application.e4xmi with this method ?
> I thought at least the part labels should be manageable with
> @Inject MPart part ;
> //...
> registry.register(part::setLabel, registry::PartNameKey) ;
>
>
> But this doesn't seem to work. And of course, menus etc. couldn't be
> done at all like this.
> If I use the standard OSGi-resource bundle, I lose the benefit of the
> at-runtime language change.
> Any tips on how to proceed ... ?
>
> Thomas
Re: Locale changes at runtime [message #1451142 is a reply to message #1451069] Thu, 23 October 2014 11:50 Go to previous messageGo to next message
Thomas Elskens is currently offline Thomas ElskensFriend
Messages: 159
Registered: September 2014
Location: Brussels - Belgium
Senior Member
I've joined a little demo in attachment : the only things to translate are the name of the pane & the menu items. The resource bundles are found at the default localion, OSGI-INF/I10n/.

I wonder if the problem is not simply the way I try to set the new Locale (code in handlers.SwitchLanguage :

"context.set(TranslationService.LOCALE, param);" works for the translation of source code, perhaps not for the translation of Application.e4xmi ?

I also tried (without succes either) :

  • System.setProperty("osgi.nl", param) ;
  • Locale.setDefault(Locale.forLanguageTag(param));

Re: Locale changes at runtime [message #1451151 is a reply to message #1451142] Thu, 23 October 2014 12:09 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Well to change the locale you need to use the ILocaleChangeService

@Inject
ILocaleChangeService lcs;

//...

lcs.changeApplicationLocale(...)

Tom


On 23.10.14 13:50, Thomas Elskens wrote:
> I've joined a little demo in attachment : the only things to translate are the name of the pane & the menu items. The resource bundles are found at the default localion, OSGI-INF/I10n/.
>
> I wonder if the problem is not simply the way I try to set the new Locale (code in handlers.SwitchLanguage :
>
> "context.set(TranslationService.LOCALE, param);" works for the translation of source code, perhaps not for the translation of Application.e4xmi ?
>
> I also tried (without succes either) :
>
> System.setProperty("osgi.nl", param) ;
> Locale.setDefault(Locale.forLanguageTag(param));
>
>
Re: Locale changes at runtime [message #1451186 is a reply to message #1451151] Thu, 23 October 2014 13:02 Go to previous messageGo to next message
Thomas Elskens is currently offline Thomas ElskensFriend
Messages: 159
Registered: September 2014
Location: Brussels - Belgium
Senior Member
Much better now, all the menu items are automatically translated, and the part labels in the demo work fine too.

There is, however, one thing that still not works: the part labels in case the parts are shared elements, and are referenced to by placeholders in perspectives. Is this something I should report or is it more likely I'm doing something wrong ... ?

Thomas
Re: Locale changes at runtime [message #1451190 is a reply to message #1451186] Thu, 23 October 2014 13:07 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Yes - sounds like a bug in the renderers.

Tom

On 23.10.14 15:02, Thomas Elskens wrote:
> Much better now, all the menu items are automatically translated, and
> the part labels in the demo work fine too.
> There is, however, one thing that still not works: the part labels in
> case the parts are shared elements, and are referenced to by
> placeholders in perspectives. Is this something I should report or is it
> more likely I'm doing something wrong ... ?
>
> Thomas
Re: Locale changes at runtime [message #1451216 is a reply to message #1451190] Thu, 23 October 2014 13:46 Go to previous messageGo to next message
Thomas Elskens is currently offline Thomas ElskensFriend
Messages: 159
Registered: September 2014
Location: Brussels - Belgium
Senior Member
Done: https://bugs.eclipse.org/bugs/show_bug.cgi?id=448499.
Re: Locale changes at runtime [message #1451217 is a reply to message #1451190] Thu, 23 October 2014 13:47 Go to previous messageGo to next message
Thomas Elskens is currently offline Thomas ElskensFriend
Messages: 159
Registered: September 2014
Location: Brussels - Belgium
Senior Member
Done: https://bugs.eclipse.org/bugs/show_bug.cgi?id=448499.
Re: Locale changes at runtime [message #1451218 is a reply to message #1451190] Thu, 23 October 2014 13:48 Go to previous message
Thomas Elskens is currently offline Thomas ElskensFriend
Messages: 159
Registered: September 2014
Location: Brussels - Belgium
Senior Member
Done https://bugs.eclipse.org/bugs/show_bug.cgi?id=448499.
Previous Topic:No repository found at http://download.eclipse.org/efxclipse/compiler-released.
Next Topic:Suggestion to modify your releng/pom.xml
Goto Forum:
  


Current Time: Fri Apr 26 20:45:56 GMT 2024

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

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

Back to the top