Java, Eclipse and Web programming Tutorials
Follow me on twitter About Lars Vogel

Eclipse RCP and Plugin Internationalization - Tutorial

Lars Vogel

Version 0.1

16.08.2009

Revision History
Revision 0.116.08.2009Lars Vogel
Separated from http://www.vogella.de/articles/RichClientPlatform/article.html

Eclipse Internationalization

This article describes how to externalize your strings in Eclipse RCP and Eclipse plugins and how to support different languages.

This article is based on Eclipse 3.5 (Eclipse Galileo).


Table of Contents

1. Eclipse Plugin and RCP internationalization
1.1. Externalize strings - Multi Languages
1.2. Select the message.properties file
2. Thank you
3. Questions and Discussion
4. Links and Literature
4.1. Source Code
4.2. Eclipse Resources
4.3. Other Resources

1. 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.

Tip

You can use the runtime parameter -nl to pass additional parameters for this message.properties should be selected. E.g. if two departments are using the same RCP application but the labels should be labeled differently create message_app1.properties and message_app2.properties and pass -nl app1 or -nl app2 to the runtime argument of the launch configuration (or the product configuration as Program Arguments in the Launching tab.

2. Thank you

Thank you for practicing with this tutorial.

Please note that I maintain this website in my private time. If you like the information I'm providing please help me by donating.

3. Questions and Discussion

For questions and discussion around this article please use the www.vogella.de Google Group. Also if you note an error in this article please post the error and if possible the correction to the Group.

I believe the following is a very good guideline for asking questions in general and also for the Google group How To Ask Questions The Smart Way.

4. Links and Literature

4.1. Source Code

http://www.vogella.de/code/codeeclipse.html Source Code of Examples

4.2. Eclipse Resources

http://www.eclipse.org/articles/Article-SWT-graphics/SWT_graphics.html SWT Graphics

http://www-128.ibm.com/developerworks/opensource/library/os-ecllink// View linking, e.g. how can view 1 react to selection changes in view 2

http://www.eclipse.org/articles/article.php?file=Article-Understanding-Layouts/index.html Understanding Layout in SWT, updated version by Wayne Beaton

http://www.eclipse.org/articles/article.php?file=Article-AddingHelpToRCP/index.html Adding help to an Eclipse RCP application

http://wiki.eclipse.org/index.php/JFaceSnippets JFace Snippets (Code Examples for certain tasks)

http://www.eclipse.org/swt/snippets/ SWT Snippets (Code Examples for certain tasks)