I am working on Java application which should support English, Russia and Korean languages.
So I have prepared properties files in unicode for each languages. Then I get some String value using _ function from bundle to set it to
- JLabel
- JTextArea
InputStream stream = LocaleManager.class.getClassLoader().getResourceAsStream(path);
ResourceBundle bundle = new PropertyResourceBundle(new InputStreamReader(stream, "UTF-8"));
public static String _(String key) {
return bundle.getString(key);
}
For English and Russian it works perfect. For Korean JTextArea shows Korean charecters correctly but JLabel does not. It shows squares and in Eclipse console it shows ??, however Russia characters can be shown correctly in Eclipse console.
So seems like problem with JLabel.
As @mKorbel easily identified the problem was with JLabel font.
On application startup identify the language from Locale.getDefault() or ask the user to select.
Then generate the path to pick .properties file according to the language selected.
In the file for Korean language I put (I use Eclipse AnyEdit plugin)
Swimming=\u0412\u043e\u0434\u043d\u043e\u0435
Running=\u0411\u044b\u0441\u0442\u0440\u043e\u0435