Java – How to implement multilanguage in Java/Swing applications

internationalizationjavamultilingualswing

What are the different ways of implementing multilingual support in Swing applications?

Are you using ResourceBundle with property file and implementing it in every frame? Does it work good for you? What if you use some kind of GUI editor? Is there any other way around?

At work we are using Matisse4MyEclipse and the code gets regenerated every time we save the screen, so simply using Externalize Strings won't work here. One way is to define it as custom property for each component, which is very annoying. Another way is to go over the multilanguage components and their properties again after matisse's generated code, which is a pain, too.

Best Solution

Well, you had to use ResourceBundles. But if you are setting the componet text property use instead of human readable text the text for RB.getString(). Then if the Matisse regenerates form the bundle key will stay and localization will work. Example:

I will use this image from Matisse pages:
Illustration
(source: myeclipseide.com) .

there you can see the the property text. There is value "My New Label". Instead of this you can use rb.getString("myNewLabel.my.message") where rb is ResourceBundle. The only problem should be too intelligent properties editor going against you. I never work with any wysiwyg editor (personal preference, I do always UI design by hand).