2
votes

In Swing, if I want to set the default locale used by components, I can call JComponent.setDefaultLocale(). I want to do the same thing in SWT/JFace, so my JFace dialogs use a locale of my choosing to display the OK/Cancel buttons, etc. Is there an equivalent method in the SWT/JFace API that I can call?

I am aware that I could call Locale.setDefault(), but I would like to avoid this because there are other parts of the application where I need this to be the system default locale, instead of the locale of my choosing.

2

2 Answers

3
votes

From what I've seen in the source code - especially where the values of IDialogConstants.OK_LABEL and similar constants originate - JFace completely relies on the default locale (Locale.getDefault()). Using SWT directly, e.g. org.eclipse.swt.widgets.MessageBox, will even ignore the Java default locale and display the dialog in the system's locale. So there seem's to be no SWT/JFace equivalent of JComponent.setDefaultLocale().

1
votes

as far as I know you should be able to use the locale of your choice using :

  • the swt-nl.jar library (to be included in your classpath)
  • setting the user.language library with something like this java -cp ... -Duser.language=fr MainApp

Please check to download the correct swt-nl pack for your needs , different are available ...

HTH jerome