• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Creating multilanguage application

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Works great!
Thank you very much!
 
Rob Spoor
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're welcome
 
Ilia Prikhodko
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
reply
    Bookmark Topic Watch Topic
  • New Topic