• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Creating multilanguage application

 
Ilia Prikhodko
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20546
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ilia Prikhodko
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Works great!
Thank you very much!
 
Rob Spoor
Sheriff
Pie
Posts: 20546
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome
 
Ilia Prikhodko
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic