creating a multilanguage application question

F

felipone

I'm writing a simple JFrame application and I want my GUI to be in 2
language versions. GUI consists of some JButtons, JMenu, JToolTip etc.

Is there a neat way (container, class build in java) assigned for
switching language versions or should do it on my own - if yes what is
the right way to do it (I fought about using setText()).

Cheers,
felipone

Sorry 4 mistakes in my English if there where any
 
S

sivasu.india

I'm writing a simple JFrame application and I want my GUI to be in 2
language versions. GUI consists of some JButtons, JMenu, JToolTip etc.

Is there a neat way (container, class build in java) assigned for
switching language versions or should do it on my own - if yes what is
the right way to do it (I fought about using setText()).

Cheers,
felipone

Sorry 4 mistakes in my English if there where any

Hi,
One way to achieve this is whatever is the text content put it
separately in a file,like msg.properties.
Suppose u want for English
put the msg.properties inside a folder en.
for chinese under the folder zh_CN.
So in that file you maintain key and value
eg.

CLASS_NAME=class name<value is locale based>


so in you code you should use only the key like CLASS_NAME,but you can
use api's available to replace the key with the value based on
locale,it will fetch from that particular folder and it will show.

Locale class in java also suppports this.
 
F

felipone

Thanks for response
Hi,
One way to achieve this is whatever is the text content put it
separately in a file,like msg.properties.

How do I bind msg.properties file to my project, this is an j2se app
so in you code you should use only the key like CLASS_NAME,but you can
use api's available to replace the key with the value based on
locale,it will fetch from that particular folder and it will show.

Locale class in java also suppports this.

So I understand I have to create my classes that extend gui classes, and
put my class names into the file.


Cheers,
felipone
 
S

Simon

felipone said:
I'm writing a simple JFrame application and I want my GUI to be in 2
language versions. GUI consists of some JButtons, JMenu, JToolTip etc.

Is there a neat way (container, class build in java) assigned for
switching language versions or should do it on my own - if yes what is
the right way to do it (I fought about using setText()).

Cheers,
felipone

Sorry 4 mistakes in my English if there where any

This is the internationalisation tutorial:

http://java.sun.com/docs/books/tutorial/i18n/index.html

Basically, what you do is:
- write one file with key value pairs for every language
- load the appropriate one based on the current locale into a ResourceBundle
- use the keys to retrieve the messages

Cheers,
Simon
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top