| Summary: | NLS.Bind(String string,String[] params) does not retrieve right string | ||
|---|---|---|---|
| Product: | [Eclipse Project] Equinox | Reporter: | manasa <manasa.priya.c> |
| Component: | Framework | Assignee: | equinox.framework-inbox <equinox.framework-inbox> |
| Status: | RESOLVED INVALID | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | pwebster, remy.suen, tjwatson |
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows 7 | ||
| Whiteboard: | |||
This test seems to be invalid because you do not double '' for Couldn't when trying to format the message. Similar results are shown by MessageFormat. See the following test which tries both NLS and MessageFormat with "Couldn't" and "Couldn''t"
// must double '' for Couldn't
String test = NLS.bind("Couldn''t convert ''{0}'' to int",
new String[] {"Test0"});
assertEquals("Wrong result", "Couldn't convert 'Test0' to int", test);
test = MessageFormat.format("Couldn''t convert ''{0}'' to int",
new String[] {"Test0"});
assertEquals("Wrong result", "Couldn't convert 'Test0' to int", test);
// See what happens if not '' for Couldn't
test = NLS.bind("Couldn't convert ''{0}'' to int",
new String[] {"Test0"});
assertEquals("Wrong result", "Couldnt convert {0}' to int", test);
test = MessageFormat.format("Couldn't convert ''{0}'' to int",
new String[] {"Test0"});
assertEquals("Wrong result", "Couldnt convert '{0}' to int", test);
The only questionable behavior difference is MessageFormat seems to recover a bit differently than NLS because it uses '{0}' where NLS is missing the first qoute {0}'
|
Build Identifier: Build id: I20100608-0911 We are using NLS.Bind() in our globalization to bind the string which contains parameters with the actual string values. NLS.bind(parameterizedString, params), when called with following parameters, parameterizedString - " Unexpected Operator: {0}", params - Test0 returns - "Unexpected Operator: Test0" where the arguement is replaced by the given string.This is the expected value. The same method when called with, parameterizedString - "Couldn't convert ''{0}'' to int" params - Test0 returns - "Couldnt convert {0}' to int" which is not the expected string. Ideally it should have been, "Couldn't convert 'Test0' to int", where the double apostrophe's are replaced by the given string within apostrophes. Reproducible: Always Steps to Reproduce: 1.Call method NLS.Bind(String string, String[] params) in Messages.java file which gets created during externalization of strings. 2.Arguements as, (Couldn't convert ''{0}'' to int, new String[]{"Test0"} 3.Will give a result "Couldnt convert {0}' to int"