Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NL (Dutch) locale in Swing does not seem to work

Tags:

java

locale

swing

I have a java application with multi-language support. When I change the language (in a preferences dialog), the language of the entire application changes, including the language of Swing components like JFileChooser. That is working perfect for English, Spanish and French. But when I choose Dutch, the language of Swing components (JFileChooser, confirm dialogs, etc.) changes to English.

Below is the code that changes the language to Dutch. Remark: for the other languages I use the same code (except for the "NL" string, of course) and it works fine.

Locale locale = new Locale("nl");
Locale.setDefault(locale);
JComponent.setDefaultLocale(locale);

I also tried creating the locale using new Locale("nl", "BE"); and new Locale("nl", "NL"); but none of them worked. Is there a problem with the Dutch locale? Or am I doing something wrong here?

like image 960
damian Avatar asked Sep 20 '11 12:09

damian


2 Answers

As stated here Dutch is not supported for User Interface Translations:

User Interface Translation Java SE Runtime Environment The user interface elements provided by the Java SE Runtime Environment 6, include Swing dialogs, messages written by the runtime environment to the standard output and standard error streams, as well as messages produced by the tools provided with the JRE. These user interface elements are localized into the following languages:

Language Locale ID Chinese (Simplified) zh_CN
Chinese (Traditional) zh_TW
English en
French fr
German de
Italian it
Japanese ja
Korean ko
Portuguese (Brazilian) pt_BR
Spanish es
Swedish sv

like image 118
Oosterman Avatar answered Sep 18 '22 02:09

Oosterman


Some years to late... But you can also create a wrapper class like this

public class DutchLocale {
    static public final Locale NL = new Locale("nl", "NL");
}
like image 38
Pol Avatar answered Sep 20 '22 02:09

Pol