ICU-10880 The approved ICU syntax has )$ being the end of the plural rule substitution.

X-SVN-Rev: 36207
This commit is contained in:
George Rhoten 2014-08-20 18:52:16 +00:00
parent 42d4d14094
commit aef79ee32c
3 changed files with 12 additions and 11 deletions

View file

@ -382,7 +382,7 @@ final class NFRule {
}
ruleText = this.ruleText;
int pluralRuleStart = ruleText.indexOf("$(");
int pluralRuleEnd = (pluralRuleStart >= 0 ? ruleText.indexOf(')', pluralRuleStart) : -1);
int pluralRuleEnd = (pluralRuleStart >= 0 ? ruleText.indexOf(")$", pluralRuleStart) : -1);
if (pluralRuleEnd >= 0) {
int endType = ruleText.indexOf(',', pluralRuleStart);
if (endType < 0) {
@ -697,10 +697,10 @@ final class NFRule {
}
else {
pluralRuleStart = ruleText.indexOf("$(");
int pluralRuleEnd = ruleText.indexOf(')', pluralRuleStart);
int pluralRuleEnd = ruleText.indexOf(")$", pluralRuleStart);
int initialLength = toInsertInto.length();
if (pluralRuleEnd < ruleText.length() - 1) {
toInsertInto.insert(pos, ruleText.substring(pluralRuleEnd + 1));
toInsertInto.insert(pos, ruleText.substring(pluralRuleEnd + 2));
}
toInsertInto.insert(pos, rulePatternFormat.format((long)(number/Math.pow(radix, exponent))));
if (pluralRuleStart > 0) {
@ -739,10 +739,10 @@ final class NFRule {
}
else {
pluralRuleStart = ruleText.indexOf("$(");
int pluralRuleEnd = ruleText.indexOf(')', pluralRuleStart);
int pluralRuleEnd = ruleText.indexOf(")$", pluralRuleStart);
int initialLength = toInsertInto.length();
if (pluralRuleEnd < ruleText.length() - 1) {
toInsertInto.insert(pos, ruleText.substring(pluralRuleEnd + 1));
toInsertInto.insert(pos, ruleText.substring(pluralRuleEnd + 2));
}
toInsertInto.insert(pos, rulePatternFormat.format((long)(number/Math.pow(radix, exponent))));
if (pluralRuleStart > 0) {
@ -1164,7 +1164,7 @@ final class NFRule {
int start = position.getBeginIndex();
if (start >= 0) {
int pluralRuleStart = ruleText.indexOf("$(");
int pluralRuleSuffix = ruleText.indexOf(')', pluralRuleStart) + 1;
int pluralRuleSuffix = ruleText.indexOf(")$", pluralRuleStart) + 2;
int matchLen = position.getEndIndex() - start;
String prefix = ruleText.substring(0, pluralRuleStart);
String suffix = ruleText.substring(pluralRuleSuffix);

View file

@ -434,7 +434,7 @@ import com.ibm.icu.util.UResourceBundleIterator;
* <td>Omit the optional text if multiplying the number by the rule's base value yields 1.</td>
* </tr>
* <tr>
* <td width="37">$(cardinal,<i>plural syntax</i>)</td>
* <td width="37">$(cardinal,<i>plural syntax</i>)$</td>
* <td width="23"></td>
* <td width="165" valign="top">in all rule sets</td>
* <td>This provides the ability to choose a word based on the number divided by the radix to the power of the
@ -443,7 +443,7 @@ import com.ibm.icu.util.UResourceBundleIterator;
* as the same base value for parsing.</td>
* </tr>
* <tr>
* <td width="37">$(ordinal,<i>plural syntax</i>)</td>
* <td width="37">$(ordinal,<i>plural syntax</i>)$</td>
* <td width="23"></td>
* <td width="165" valign="top">in all rule sets</td>
* <td>This provides the ability to choose a word based on the number divided by the radix to the power of the

View file

@ -556,7 +556,7 @@ public class RbnfTest extends TestFmwk {
public void TestPluralRules() {
String enRules = "%digits-ordinal:"
+ "-x: >>;"
+ "0: =#,##0=$(ordinal,one{st}two{nd}few{rd}other{th});";
+ "0: =#,##0=$(ordinal,one{st}two{nd}few{rd}other{th})$;";
RuleBasedNumberFormat enFormatter = new RuleBasedNumberFormat(enRules, ULocale.ENGLISH);
String[][] enTestData = {
{ "1", "1st" },
@ -612,8 +612,8 @@ public class RbnfTest extends TestFmwk {
+ "200: <<сти[ >>];"
+ "300: <<ста[ >>];"
+ "500: <<сот[ >>];"
+ "1000: << $(cardinal,one{тысяча}few{тысячи}other{тысяч})[ >>];"
+ "1000000: << $(cardinal,one{миллион}few{миллионы}other{миллионов})[ >>];";
+ "1000: << $(cardinal,one{тысяча}few{тысячи}other{тысяч})$[ >>];"
+ "1000000: << $(cardinal,one{миллион}few{миллионы}other{миллионов})$[ >>];";
RuleBasedNumberFormat ruFormatter = new RuleBasedNumberFormat(ruRules, new ULocale("ru"));
String[][] ruTestData = {
{ "1", "один" },
@ -630,6 +630,7 @@ public class RbnfTest extends TestFmwk {
{ "11,000", "одиннадцать тысяч" },
{ "21,000", "двадцать один тысяча" },
{ "22,000", "двадцать два тысячи" },
{ "25,001", "двадцать пять тысяч один" },
};
doTest(ruFormatter, ruTestData, true);