When you just get in contact with Eclipse, you often see some strange annotations in the official example, such as shell.Settext (Messages.GetString ("Testref.Hello")); // $ NON-NLS-1 $ NON-NLS What is the representative? At that time, after a while, I ignored this problem. When I read Rich Client Tutorial Part 2, the unexpected discovery of the true meaning of this line of comments ... ^ _ ^ is really harvest.
This actually supports one way of I18n in Eclipse, the standard structure of Eclipse, defines all String constants to .properties, such as Testref.Hello in the above block, actually a key testref.Hello = Hello in PROPERTIES
Now everyone may guess the meaning of $ NON-NLS-1 $, I personally guess him may be the abbreviation of Non Need Localize String 1. The RCP document is the String $ NON-NLS-1 $ IS A HINT for Both The Compiler and the Externalization Wizard That The First Character String On This Line is a tag or keyword of some sort and shop not be localized. That is to say $ NON-NLS-1 $ indicates that the first String type variable of the Bank is a label or keyword, which does not need to be localized.
TestRef.java
Public class testref {public static void main (string [] args) {shell shell = new shell (); shell.getstring ("Testref.Hello"); // $ NON-NLS-1 $}
Messages.java
public class Messages {private static final String BUNDLE_NAME = "test"; // $ NON-NLS-1 $ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle (BUNDLE_NAME); private Messages () {} public static String getString (String key) {Try {Return Resource_bundle.getstring (key);} catCH (MissingResourceException e) {return '!' Key '!';}}} Test.properties
TestRef.hello = Hello