RSS

Search Engine

Thursday, July 1, 2010

Eclipse Plugin and RCP internationalization

1.1. Externalize strings - Multi Languages

The following describes the Eclipse way of replacing strings and how to select them.

Create a new RCP project "MultiLanguage". See Eclipse RCP tutorial for details. Use "RCP application with a view" as template.

Change the View.java to the following.

    
package multilanguage;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.part.ViewPart;

public class View extends ViewPart {
public static final String ID = "MultiLanguage.view";


public void createPartControl(Composite parent) {
Label label = new Label(parent, SWT.BORDER);
label.setText("This is a hardcoded text");
}

/**
* Passing the focus request to the viewer's control.
*/
public void setFocus() {
}
}

Right mouse-click on the source code. Select Source -> Externalize Strings. Select the strings which should be externalized

Press finished. As a result a class Message.java is created which contains static member variables which can be used in the coding as String replacements. The message.properties contain the real strings.

1.2. Select the message.properties file

Copy message.properties to message_de.properties or message_en.properties to support different strings for different languages.

0 comments:

Post a Comment