Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Visual Editor (VE) » Localising strings on form?
Localising strings on form? [message #98495] Wed, 20 July 2005 08:11 Go to next message
Matt Doran is currently offline Matt DoranFriend
Messages: 4
Registered: July 2009
Junior Member
Hi,

I was wondering what the recommended approach is for doing localisation
of strings on a VE form.

I've got my form working with hard-coded strings, but when I replace
those strings with function calls to get messages from message bundles,
the Visual editor stops working properly. And the labels that get their
values from message bundles don't appear anymore....

The only way I can think of is to set the strings on labels after the
form code generated by the VE has run (e.g. after the initialise code).

Is this the way to do it? Or is there a more elegant approach that I'm
missing?

I'm using Eclipse 3.1 and the latest stable integration build of VE.

Regards,
Matt
Re: Localising strings on form? [message #98525 is a reply to message #98495] Wed, 20 July 2005 09:23 Go to previous messageGo to next message
Joe Winchester is currently offline Joe WinchesterFriend
Messages: 496
Registered: July 2009
Senior Member
Hi matt,

> I was wondering what the recommended approach is for doing localisation
> of strings on a VE form.

From the package explorer against the class use the pop-up menu
Source>Externalize Strings. De-select the strings you don't want to
exterliaze (the wizard will scan the file for Strings and some of them
might be program constants that aren't user visible and you don't want
to translate). The pattern of code generated is one the VE will
reocgnize so on re-open you will get the correct bundle entry shown.
If you do have multiple language bundles in your project you can change
which one the VE loads by setting the locale on the preferences page.

> I've got my form working with hard-coded strings, but when I replace
> those strings with function calls to get messages from message bundles,
> the Visual editor stops working properly. And the labels that get their
> values from message bundles don't appear anymore....

Can you paste a snippit of the source code so we can take a look and see
why the VE can't parse and evalute it ?

> The only way I can think of is to set the strings on labels after the
> form code generated by the VE has run (e.g. after the initialise code).
> Is this the way to do it? Or is there a more elegant approach that I'm
> missing?

Try the pop-up menu to Externalize Strings that should work OK. We do
have a line item to do a thorough job with externalization but for now
this is the recommended route and one that seems to work OK.

Best regards,

Joe Winchester
Re: Localising strings on form? [message #98886 is a reply to message #98525] Wed, 20 July 2005 23:59 Go to previous message
Matt Doran is currently offline Matt DoranFriend
Messages: 4
Registered: July 2009
Junior Member
Hi Joe,

Thanks for the response....


> From the package explorer against the class use the pop-up menu
> Source>Externalize Strings. De-select the strings you don't want to
> exterliaze (the wizard will scan the file for Strings and some of them
> might be program constants that aren't user visible and you don't want
> to translate).

We did experiment with the eclipse externalize function early on in our
project but we opted for some home-grown helpers to assist formatting
messages etc. I can't remember why we went this way...

>
>> I've got my form working with hard-coded strings, but when I replace
>> those strings with function calls to get messages from message
>> bundles, the Visual editor stops working properly. And the labels
>> that get their values from message bundles don't appear anymore....
>
>
> Can you paste a snippit of the source code so we can take a look and see
> why the VE can't parse and evalute it ?

I replaced lines like this:

_costLabel.setText("Cost");

with this:

_costLabel.setText(getMessage("cost"));

The getMessage() function looks something like the following. It's
nothing special. It would usually do the message bundle
lookup/formatting, but even changed to just return a modified string
causes the same problems ....

private String getMessage(String key) {
// Would usually do a bundle lookup, but even this fails
return "!" + key + "!";
}


After I've changed this, the field does not even appear.

And if I do the same for the frame title things get even worse. I
initially get a little indicator in the title bar showing an error. But
if I close and reopen the form, the form no longer displays.

>
>> The only way I can think of is to set the strings on labels after the
>> form code generated by the VE has run (e.g. after the initialise
>> code). Is this the way to do it? Or is there a more elegant approach
>> that I'm missing?
>
>
> Try the pop-up menu to Externalize Strings that should work OK. We do
> have a line item to do a thorough job with externalization but for now
> this is the recommended route and one that seems to work OK.

For now I'm just post-processing the fields after initialise ... it
works but is not ideal...

Thanks again for your response.

Matt
Re: Localising strings on form? [message #609112 is a reply to message #98495] Wed, 20 July 2005 09:23 Go to previous message
Joe Winchester is currently offline Joe WinchesterFriend
Messages: 496
Registered: July 2009
Senior Member
Hi matt,

> I was wondering what the recommended approach is for doing localisation
> of strings on a VE form.

From the package explorer against the class use the pop-up menu
Source>Externalize Strings. De-select the strings you don't want to
exterliaze (the wizard will scan the file for Strings and some of them
might be program constants that aren't user visible and you don't want
to translate). The pattern of code generated is one the VE will
reocgnize so on re-open you will get the correct bundle entry shown.
If you do have multiple language bundles in your project you can change
which one the VE loads by setting the locale on the preferences page.

> I've got my form working with hard-coded strings, but when I replace
> those strings with function calls to get messages from message bundles,
> the Visual editor stops working properly. And the labels that get their
> values from message bundles don't appear anymore....

Can you paste a snippit of the source code so we can take a look and see
why the VE can't parse and evalute it ?

> The only way I can think of is to set the strings on labels after the
> form code generated by the VE has run (e.g. after the initialise code).
> Is this the way to do it? Or is there a more elegant approach that I'm
> missing?

Try the pop-up menu to Externalize Strings that should work OK. We do
have a line item to do a thorough job with externalization but for now
this is the recommended route and one that seems to work OK.

Best regards,

Joe Winchester
Re: Localising strings on form? [message #609147 is a reply to message #98525] Wed, 20 July 2005 23:59 Go to previous message
Matt Doran is currently offline Matt DoranFriend
Messages: 4
Registered: July 2009
Junior Member
Hi Joe,

Thanks for the response....


> From the package explorer against the class use the pop-up menu
> Source>Externalize Strings. De-select the strings you don't want to
> exterliaze (the wizard will scan the file for Strings and some of them
> might be program constants that aren't user visible and you don't want
> to translate).

We did experiment with the eclipse externalize function early on in our
project but we opted for some home-grown helpers to assist formatting
messages etc. I can't remember why we went this way...

>
>> I've got my form working with hard-coded strings, but when I replace
>> those strings with function calls to get messages from message
>> bundles, the Visual editor stops working properly. And the labels
>> that get their values from message bundles don't appear anymore....
>
>
> Can you paste a snippit of the source code so we can take a look and see
> why the VE can't parse and evalute it ?

I replaced lines like this:

_costLabel.setText("Cost");

with this:

_costLabel.setText(getMessage("cost"));

The getMessage() function looks something like the following. It's
nothing special. It would usually do the message bundle
lookup/formatting, but even changed to just return a modified string
causes the same problems ....

private String getMessage(String key) {
// Would usually do a bundle lookup, but even this fails
return "!" + key + "!";
}


After I've changed this, the field does not even appear.

And if I do the same for the frame title things get even worse. I
initially get a little indicator in the title bar showing an error. But
if I close and reopen the form, the form no longer displays.

>
>> The only way I can think of is to set the strings on labels after the
>> form code generated by the VE has run (e.g. after the initialise
>> code). Is this the way to do it? Or is there a more elegant approach
>> that I'm missing?
>
>
> Try the pop-up menu to Externalize Strings that should work OK. We do
> have a line item to do a thorough job with externalization but for now
> this is the recommended route and one that seems to work OK.

For now I'm just post-processing the fields after initialise ... it
works but is not ideal...

Thanks again for your response.

Matt
Previous Topic:Properties sheet
Next Topic:VE 1.1 Release candidate 1 available
Goto Forum:
  


Current Time: Thu Apr 25 18:59:35 GMT 2024

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

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

Back to the top