In our Eclipse RCP application, all Strings are externalized and present in 2 languages, which works just fine. E.g. I got a Messages.java like this:
public class Messages extends NLS
{
private static final String BUNDLE_NAME =
"abc.fixedcolumns.messages"; //$NON-NLS-1$
public static String additionalReq;
static
{
// initialize resource bundle
NLS.initializeMessages( BUNDLE_NAME, Messages.class );
}
private Messages()
{
super();
}
With the matching messages_de.properties and messages_en.properties.
It works fine, starting the application in english shows the english strings and in german shows the german ones.
Now I need to get some English strings in the german version. How can this be accomplished?
(One attempt was to change the Locale of the JVM, get the string and change it back, but this would be a very bad solution)
You don't have to put all your messages in the language specific properties file. NLS
will also look in a messages.properties
file. You could put the English only messages there and not put anything in the language specific properties.
Other than that NLS
does not support doing a lookup for anything other than the current locale. You could make your own version of the class to do what you want, NLS
is not very big.
Eclipse e4
RCPs do support more flexible translation systems.