I18n is bad enough, but in RAP there is even more typing to do :-(
You need to create a Messages class and add a public field for every string you need to translate. You then have to create a properties file for each language and add the texts. The convention for key names is Classname_fieldname.
For example:
Messages.java
...
public String MyView_controltext;
...
Messages.properties
...
MyView_controltext = Hello World
...
MyView.java
...
control.setText(Messages.get().MyView_controltext);
...
I made life a liitle easier by adding a template. Window -> Preferences -> Java -> Editor -> Templates -> New...
Name = msg (or whatever you like)
Pattern = Messages.get().${enclosing_type}_${cursor}
Now I can just type 'msg' <Ctrl>+Space and I get most of what I need.
I can also recommend the Eclipse ResourceBundle Editor at http://sourceforge.net/projects/eclipse-rbe/.
No comments:
Post a Comment