Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Best practise for using Translation Service (Luna M6)
Best practise for using Translation Service (Luna M6) [message #1318603] Sun, 27 April 2014 15:37 Go to next message
Ralf Heydenreich is currently offline Ralf Heydenreich
Messages: 106
Registered: July 2009
Senior Member
Hi all,
I'm looking for a practical way for the i18n of my application. I found
this blog post [1], but I think it could go easier. In my current
application (Eclipse 3.7 RCP) there I've a construction like this:

import static my.legacy.rcp.app.Translation._
....
(inside a method)
System.out.println(_("message.key"));

The "_" method is looking for the key and formats the message in the
right way.

I know that it's perhaps not the most optimal solution, but it worked
for now. If I want to use the TranslationService this construction fails
(or at least I don't know how to implement it), because there's no
static access to it. I want to use the "classic" way for my translation
files (OSGI-INF folder).

How could I get a similar solution in Eclipse 4 like the above mentioned?

Thanks in advance,
Ralf.


[1]
http://blog.vogella.com/2013/05/22/eclipse-internationalization-part-24-new-message-extension-by-dirk-fauth-and-tom-schindl/
Re: Best practise for using Translation Service (Luna M6) [message #1318734 is a reply to message #1318603] Sun, 27 April 2014 17:24 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5245
Registered: July 2009
Senior Member
The translation stuff in e4 uses methods instead of string literals
because this:
a) has less overhead from a memory point of view
b) is compiler checked

So your code would look like this:

@Inject
@Translation
Messages _;

System.out.println(_.message_key());

Tom

On 27.04.14 21:37, Ralf Heydenreich wrote:
> Hi all,
> I'm looking for a practical way for the i18n of my application. I found
> this blog post [1], but I think it could go easier. In my current
> application (Eclipse 3.7 RCP) there I've a construction like this:
>
> import static my.legacy.rcp.app.Translation._
> ...
> (inside a method)
> System.out.println(_("message.key"));
>
> The "_" method is looking for the key and formats the message in the
> right way.
>
> I know that it's perhaps not the most optimal solution, but it worked
> for now. If I want to use the TranslationService this construction fails
> (or at least I don't know how to implement it), because there's no
> static access to it. I want to use the "classic" way for my translation
> files (OSGI-INF folder).
>
> How could I get a similar solution in Eclipse 4 like the above mentioned?
>
> Thanks in advance,
> Ralf.
>
>
> [1]
> http://blog.vogella.com/2013/05/22/eclipse-internationalization-part-24-new-message-extension-by-dirk-fauth-and-tom-schindl/
>
Re: Best practise for using Translation Service (Luna M6) [message #1322280 is a reply to message #1318734] Tue, 29 April 2014 15:42 Go to previous messageGo to next message
Ralf Heydenreich is currently offline Ralf Heydenreich
Messages: 106
Registered: July 2009
Senior Member
Am 27.04.2014 23:24, schrieb Tom Schindl:
> The translation stuff in e4 uses methods instead of string literals
> because this:
> a) has less overhead from a memory point of view
> b) is compiler checked
>
> So your code would look like this:
>
> @Inject
> @Translation
> Messages _;
>
> System.out.println(_.message_key());
>
> Tom
>

Ok, I get it. Does it really mean that I have to maintain TWO files?
Then I have bundle_XX.properties and an accompanying Messages class
file... This cries for a little generator...

Greetz,
Ralf.
Re: Best practise for using Translation Service (Luna M6) [message #1323447 is a reply to message #1322280] Wed, 30 April 2014 05:03 Go to previous message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5245
Registered: July 2009
Senior Member
yes you need to maintain both

Tom

On 29.04.14 21:42, Ralf Heydenreich wrote:
> Am 27.04.2014 23:24, schrieb Tom Schindl:
>> The translation stuff in e4 uses methods instead of string literals
>> because this:
>> a) has less overhead from a memory point of view
>> b) is compiler checked
>>
>> So your code would look like this:
>>
>> @Inject
>> @Translation
>> Messages _;
>>
>> System.out.println(_.message_key());
>>
>> Tom
>>
>
> Ok, I get it. Does it really mean that I have to maintain TWO files?
> Then I have bundle_XX.properties and an accompanying Messages class
> file... This cries for a little generator...
>
> Greetz,
> Ralf.
>
Previous Topic:EMenuService is null
Next Topic:error if opening Application.e4xmi
Goto Forum:
  


Current Time: Sat Jul 26 09:28:11 EDT 2014

Powered by FUDForum. Page generated in 0.02456 seconds