6

I am creating a standalone SWT/JFace application.

I used to use plain old SWT MessageBox:

int style = SWT.APPLICATION_MODAL | SWT.YES | SWT.NO;
MessageBox messageBox = new MessageBox (getShell(), style);
messageBox.setText ("Question");
messageBox.setMessage ("So?");
boolean result = messageBox.open() == SWT.YES;

I try to switch to JFace MessageDialog

boolean result = MessageDialog.openQuestion(getShell(), "Question", "So?");

The problem I have is that in SWT, the Yes and No button labels are translated in my language, while in JFace it is not the case. Any idea?

My referenced jars are swt 3.8.0, jface 3.8.0, and jface dependencies core.commands 3.6.1 and equinox.common 3.6.100.

Steph
  • 1,989
  • 14
  • 18

2 Answers2

11

In the MessageBox class of SWT the labels are set by the OS. For JFace you have to provide your own translation file. You can get one for your language here. Of course you can also provide it on your own. This link explains how to use resource bundles for translation. You find the original translation file under org/eclipse/jface/messages.properties . You have to add your own translation file (messages_[language code].properties) to the same package path in your project. Note that resource bundles have nothing in common with OSGi bundles.

Tobias Willig
  • 1,124
  • 7
  • 16
  • 1
    In the babel link you provided, I digged into the different jars and finally found what I was looking for: org.eclipse.jface.nl_fr_3.7.0. It is not 3.8 but I reckon 3.8 is only a bug fix of 3.7. I added it to my classpath and it works like a charm. Thanks. – Steph Apr 07 '13 at 10:14
0

I had the same problem.I was using Messagebox of SWT. Since OS has to take care of translations I tested it by changing the Region settings in control panel and it did not help. We have to switch OS language to achieve that. For a windows 7 user one has to upgrade to Windows ultimate package. And here is how you do it. http://answers.microsoft.com/en-us/windows/forum/windows_7-desktop/how-to-change-system-language-of-windows-7-home/d58fb37b-cb02-41c8-986f-22582fd35a12.

I haven't tried it, but worth a shot.

Ram K
  • 76
  • 5