i18n in swing, trouble

S

Schlum

Hi,

I am building my first Gui with Swing, and in the same time I need to
use the i18n to make it work in Japanese and English.

I use Eclipse and its great Visual Editor to save time, all my files are
utf8 encoded. And, I am under WinXp...

My trouble is the following :
-> If I make a jMenu with some japanese hardcoded text, it appears fine
in my application.
-> If I use a ResourceBundle to get the text, I have garbage. I use the
following line: myMenu.setText(myBundleResource.getString("myTest"));
The .properties files for the japanese is also in Utf8

Do you have any idea why the text in the .properties file is not passed
correctly ? Any help would be really appreciated.

Best Regards,
Schlum
 
H

hiwa

Schlum ã®ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸:
Hi,

I am building my first Gui with Swing, and in the same time I need to
use the i18n to make it work in Japanese and English.

I use Eclipse and its great Visual Editor to save time, all my files are
utf8 encoded. And, I am under WinXp...

My trouble is the following :
-> If I make a jMenu with some japanese hardcoded text, it appears fine
in my application.
-> If I use a ResourceBundle to get the text, I have garbage. I use the
following line: myMenu.setText(myBundleResource.getString("myTest"));
The .properties files for the japanese is also in Utf8

Do you have any idea why the text in the .properties file is not passed
correctly ? Any help would be really appreciated.

Best Regards,
Schlum
Did you use native2ascii tool for creating the ja.properties?
Do you set Locale.ja in your application?
 
S

Schlum

hiwa said:
Schlum ã®ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸:

Did you use native2ascii tool for creating the ja.properties?
Do you set Locale.ja in your application?
Hi, thank you for your answer,

I actually do not know what is native2ascii, I am going to look at it
right away.

Here is the way i did it:

I declared a private ResourceBundle messages into my gui class:
private ResourceBundle messages;

I then initialize it in the constructor of my class:

String langue = new String("ja");
String pays = new String("JP");
Locale currentLocale= new Locale(langue, pays);
this.messages = ResourceBundle.getBundle("messages", currentLocale);

The languages files are messages.properties, messages_ja_JP.properties
and messages_us_US.properties. They are in the path, as I can display
the English correctly.

For the moment, I do not detect the computer's local as I am developing
in a English environment.

Do you see something wrong in the way i did this ?

Thank's for your help,
Schlum.
 
H

hiwa

Schlum ã®ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸:
Hi, thank you for your answer,

I actually do not know what is native2ascii, I am going to look at it
right away.

Here is the way i did it:

I declared a private ResourceBundle messages into my gui class:
private ResourceBundle messages;

I then initialize it in the constructor of my class:

String langue = new String("ja");
String pays = new String("JP");
Locale currentLocale= new Locale(langue, pays);
this.messages = ResourceBundle.getBundle("messages", currentLocale);

The languages files are messages.properties, messages_ja_JP.properties
and messages_us_US.properties. They are in the path, as I can display
the English correctly.

For the moment, I do not detect the computer's local as I am developing
in a English environment.

Do you see something wrong in the way i did this ?

Thank's for your help,
Schlum.
The messages_ja.properties file should be prepared by using
native2ascii tool or \uxxxx notation for Japanese characters.
 
T

Thomas Weidenfeller

Schlum said:
The .properties files for the japanese is also in Utf8

Bad. It needs to be in ASCII/Latin-1 with any non ASCII/Latin-1 char
encoded with the \u notation.

This is difficult to write by hand, so use native2ascii to convert your
text. I would recommend to add the call to native2ascii to your build
system.
Do you have any idea why the text in the .properties file is not passed
correctly ?

Because you didn't write it correctly.

/Thomas
 
S

Schlum

Hiwa, Thomas,

Thank you very much for your help, it works perfectly now.

Have a good day,
Schlum
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,738
Latest member
TiffinyHol

Latest Threads

Top