File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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: 19785
    
  20

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: 19785
    
  20

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