Netbeans java desktop application: Resource Map internationalization
I'm trying to introduce internationalization support for my app...I created it as a netbeans java desktop application. Netbeans automatically introduced the following code :
public class ABC extends FrameView{
//constructor
public ABC(Singleframeapplication app)
{
//introduced by netbeans automatically
ResourceMap resourceMap=getResourceMap();
//
}
}
how do i used this resourcemap object to set the locale(eg. FR) f开发者_运维知识库or my entire app? PS:i have created ABC_FR.properties in /ABC/resources folder Thanks
I made this work by adding a call to Locale.setDefault() in the main of my app:
public static void main(String[] args) {
System.out.println(Locale.getDefault()); // the JVM defaults to es_ES on my machine, so this prints "es_ES"
Locale.setDefault(Locale.ENGLISH); // set it to English
System.out.println(Locale.getDefault()); // Now it prints "en"
launch(MyNiceApp.class, args); // my app comes up in English now
}
This is documented relatively well here: http://java.sun.com/developer/technicalArticles/J2SE/locale/
The problem with the documentation is that it discusses in detail the most complicated cases, and glosses over the most simple case of putting the whole application in a specific language, which would seem to be what most programmers would want.
精彩评论