title: How to set different Locale when using org.eclipse.osgi.util.NLS approach
body: <p>In our eclipse application we are using the method to provide localization with a dedicated nls bundle, a messages.java and localized messages_xx_XX.properties files. This works generally very nice: When running on a german Windows, we get the german strings, english ones on an english Windows etc.</p>
  
  <p>The request is now, that it shall be possible for a user to switch to a different language. So even when his Windows is set to german, he shall be able to run our software with e.g. english strings.</p>
  
  <p>This didn't look to be too difficult, because there are several documentations out there, describing various methods to switch the Locale for a Java application. E.g. by using the commandline switches -Duser.language and -Duser.country. Or by using an approach as outlined in this stackoverflow post: <a href="https://stackoverflow.com/questions/4947484/how-to-set-eclipse-console-locale-language">How to set eclipse console locale/language</a>.</p>
  
  <p>Another method for eclipse should be to use the -nl switch for eclipse as e.g. "eclipse.exe -nl en".</p>
  
  <p>Nooow: None of these approaches does work! Whatever you do on e.g. a german Windows system you'll always get the german strings, no matter what sort of approach you use.</p>
  
  <p>Digging in the issue I found, that the binding to the respective messages_xx_XX.properties files takes place in the NLS.class in the "buildVariants" method. In this method "Locale.getDefault" is called and from the return value the country- and language codes are extracted and used to combine the names of the respective .properties files.</p>
  
  <p>Unfortunately Locale.getDefault always returns de_DE on a Windows system with display language set to german (see <a href="http://blog.ej-technologies.com/2011/12/default-locale-changes-in-java-7.html" rel="nofollow noreferrer">http://blog.ej-technologies.com/2011/12/default-locale-changes-in-java-7.html</a>). So no matter what you do, it seems one can't change the default locale for a java application by using any of the methods described above.</p>
  
  <p>Or is there a way?</p>
  
  <p>It would also help us, if we would know, how to reset the nlSuffixes field in org.eclipse.osgi.util.NLS programmatically, so we could try to trigger a reload of the translation properties files.</p>