eclipse plugin:more strings externalization

This commit is contained in:
Timotei Dolean 2010-12-02 16:19:47 +00:00
parent 360ee65121
commit df211cb39d
5 changed files with 29 additions and 23 deletions

View file

@ -18,7 +18,9 @@ Require-Bundle: org.eclipse.xtext,
org.eclipse.emf.common,
org.antlr.runtime,
org.eclipse.xtext.junit;bundle-version="1.0.0",
org.wesnoth;bundle-version="1.0.0"
org.wesnoth;bundle-version="1.0.0",
org.eclipse.osgi.util;bundle-version="3.2.100",
org.eclipse.osgi;bundle-version="3.6.0"
Import-Package: org.apache.log4j
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Export-Package: org.wesnoth,

View file

@ -0,0 +1,3 @@
WMLJavaValidator.0=Incorrect closing tag name.
WMLJavaValidator.2=There is no such wml tag name.
WMLJavaValidator.3=triggered wmlkey expensive validation.

View file

@ -127,7 +127,7 @@ public abstract class WMLTests extends AbstractXtextTests
protected void checkKeyword(String input) {
// the rule name for a keyword is usually
// the keyword enclosed in single quotes
String rule = new StringBuilder("'").append(input).append("'")
String rule = new StringBuilder("'").append(input).append("'") //$NON-NLS-1$ //$NON-NLS-2$
.toString();
checkTokenisation(input, rule);
}

View file

@ -14,36 +14,36 @@ public class WMLTestsImpl extends WMLTests
//rule names in your grammar
//the names of terminal rules will be capitalised
//and "RULE_" will be appended to the front
private static final String ID="RULE_ID";
private static final String INT="RULE_INT";
private static final String WS="RULE_WS";
private static final String SL_COMMENT="RULE_SL_COMMENT";
private static final String ID="RULE_ID"; //$NON-NLS-1$
private static final String INT="RULE_INT"; //$NON-NLS-1$
private static final String WS="RULE_WS"; //$NON-NLS-1$
private static final String SL_COMMENT="RULE_SL_COMMENT"; //$NON-NLS-1$
public void testINT()
{
checkTokenisation("1", INT);
checkTokenisation("1", INT); //$NON-NLS-1$
}
public void testID(){
checkTokenisation("a", ID);
checkTokenisation("abc", ID);
checkTokenisation("abc123", ID);
checkTokenisation("abc_123", ID);
checkTokenisation("a", ID); //$NON-NLS-1$
checkTokenisation("abc", ID); //$NON-NLS-1$
checkTokenisation("abc123", ID); //$NON-NLS-1$
checkTokenisation("abc_123", ID); //$NON-NLS-1$
}
public void testSLCOMMENT(){
checkTokenisation("#comment", SL_COMMENT);
checkTokenisation("#comment\n", SL_COMMENT);
checkTokenisation("# comment \t\t comment\r\n", SL_COMMENT);
checkTokenisation("#comment", SL_COMMENT); //$NON-NLS-1$
checkTokenisation("#comment\n", SL_COMMENT); //$NON-NLS-1$
checkTokenisation("# comment \t\t comment\r\n", SL_COMMENT); //$NON-NLS-1$
}
public void testTokenSequences(){
showTokenisation("amount=+$random\n");
checkParsing("amount=+$random", "WMLKey");
showTokenisation("amount=+$random\n"); //$NON-NLS-1$
checkParsing("amount=+$random", "WMLKey"); //$NON-NLS-1$ //$NON-NLS-2$
checkTokenisation("123 abc", ID, WS, ID);
checkTokenisation("123 \t#comment\n abc", ID, WS, SL_COMMENT,WS,ID);
checkTokenisation("123 abc", ID, WS, ID); //$NON-NLS-1$
checkTokenisation("123 \t#comment\n abc", ID, WS, SL_COMMENT,WS,ID); //$NON-NLS-1$
//note that no white space is necessary!
checkTokenisation("123abc", ID);
checkTokenisation("123abc", ID); //$NON-NLS-1$
}
}

View file

@ -13,6 +13,7 @@ import org.eclipse.xtext.parsetree.LeafNode;
import org.eclipse.xtext.parsetree.NodeUtil;
import org.eclipse.xtext.validation.Check;
import org.eclipse.xtext.validation.CheckType;
import org.wesnoth.Messages;
import org.wesnoth.schema.SchemaParser;
import org.wesnoth.schema.Tag;
import org.wesnoth.wML.WMLKey;
@ -37,7 +38,7 @@ public class WMLJavaValidator extends AbstractWMLJavaValidator
public void checkFastTagName(WMLTag tag)
{
if (!tag.getName().equals(tag.getEndName()))
warning("Incorrect closing tag name.", WMLPackage.WML_TAG__END_NAME);
warning(Messages.getString("WMLJavaValidator.0"), WMLPackage.WML_TAG__END_NAME); //$NON-NLS-1$
}
// @Check(CheckType.NORMAL)
@ -54,7 +55,7 @@ public class WMLJavaValidator extends AbstractWMLJavaValidator
String searchName = parentNode.getText();
if (node.getParent().eContainer() == null) // root node
{
searchName = "root";
searchName = "root"; //$NON-NLS-1$
}
if (SchemaParser.getInstance().getTags().get(searchName) != null)
{
@ -68,7 +69,7 @@ public class WMLJavaValidator extends AbstractWMLJavaValidator
}
}
if (found == false)
warning("There is no such wml tag name.", WMLPackage.WML_TAG__NAME);
warning(Messages.getString("WMLJavaValidator.2"), WMLPackage.WML_TAG__NAME); //$NON-NLS-1$
}
}
}
@ -77,7 +78,7 @@ public class WMLJavaValidator extends AbstractWMLJavaValidator
public void checkExpensiveKeyValue(WMLKey key)
{
//TODO: add regex checking here
System.out.println("triggered wmlkey expensive validation.");
System.out.println(Messages.getString("WMLJavaValidator.3")); //$NON-NLS-1$
}
@Check(CheckType.NORMAL)