| Java, Eclipse and Web programming Tutorials |
Version 0.1
Copyright © 2009 Lars Vogel
16.08.2009
| Revision History | ||
|---|---|---|
| Revision 0.1 | 16.08.2009 | Lars Vogel |
| Separated from http://www.vogella.de/articles/RichClientPlatform/article.html | ||
Table of Contents
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.
Copy message.properties to message_de.properties or message_en.properties to support different strings for different languages.
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.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.
http://www.vogella.de/code/codeeclipse.html Source Code of Examples
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)