wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes Creating multilanguage application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Creating multilanguage application" Watch "Creating multilanguage application" New topic
Author

Creating multilanguage application

Ilia Prikhodko
Greenhorn

Joined: Apr 14, 2012
Posts: 11
Hello,
I'm developing swing application. I would like my application to be multilanguage. How can i do this?
Thanks a lot!
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

Take a look at ResourceBundle. With it you can have one properties file per language (or even language / country combination). In your code you then shouldn't use hard coded strings but use this ResourceBundle instead. To make it easier you can provide one utility class to get all the messages. For example:
The method and key names are of course entirely dependent on your application.

Now, instead of creating a button with label "Submit", you create it with label I18N.getSubmitButtonLabel(). This will then take the actual label from the correct properties file, depending on the current locale.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Ilia Prikhodko
Greenhorn

Joined: Apr 14, 2012
Posts: 11
Works great!
Thank you very much!
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

You're welcome
Ilia Prikhodko
Greenhorn

Joined: Apr 14, 2012
Posts: 11
Now other thing
For example, i have English as default language and i want to change it on another,let's say, French with Combobox. But as i have many labels and buttons i don't want to call "setText" to all of them.
Is it possible to avoid this callings?
Thanks a lot!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Creating multilanguage application
 
Similar Threads
Implementing resource bundle in javascript
IntelliJ IDEA not very popular in Europe, why ?
Passing session variable between two wars
reload messageresources
free java chat servers