mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-07 06:25:30 +00:00
ICU-11064 The approved ICU syntax has )$ being the end of the plural rule substitution.
X-SVN-Rev: 36208
This commit is contained in:
parent
aef79ee32c
commit
e79ae82c7d
3 changed files with 13 additions and 12 deletions
|
@ -54,7 +54,6 @@ NFRule::~NFRule()
|
|||
|
||||
static const UChar gLeftBracket = 0x005b;
|
||||
static const UChar gRightBracket = 0x005d;
|
||||
static const UChar gClosedParenthesis = 0x0029;
|
||||
static const UChar gColon = 0x003a;
|
||||
static const UChar gZero = 0x0030;
|
||||
static const UChar gNine = 0x0039;
|
||||
|
@ -74,6 +73,7 @@ static const UChar gXDotZero[] = {0x78, 0x2E, 0x30, 0}; /* "x.0"
|
|||
static const UChar gZeroDotX[] = {0x30, 0x2E, 0x78, 0}; /* "0.x" */
|
||||
|
||||
static const UChar gDollarOpenParenthesis[] = {0x24, 0x28, 0}; /* "$(" */
|
||||
static const UChar gClosedParenthesisDollar[] = {0x29, 0x24, 0}; /* ")$" */
|
||||
|
||||
static const UChar gLessLess[] = {0x3C, 0x3C, 0}; /* "<<" */
|
||||
static const UChar gLessPercent[] = {0x3C, 0x25, 0}; /* "<%" */
|
||||
|
@ -394,7 +394,7 @@ NFRule::extractSubstitutions(const NFRuleSet* ruleSet,
|
|||
sub2 = extractSubstitution(ruleSet, predecessor, status);
|
||||
}
|
||||
int32_t pluralRuleStart = this->ruleText.indexOf(gDollarOpenParenthesis, -1, 0);
|
||||
int32_t pluralRuleEnd = (pluralRuleStart >= 0 ? this->ruleText.indexOf(gClosedParenthesis, pluralRuleStart) : -1);
|
||||
int32_t pluralRuleEnd = (pluralRuleStart >= 0 ? this->ruleText.indexOf(gClosedParenthesisDollar, -1, pluralRuleStart) : -1);
|
||||
if (pluralRuleEnd >= 0) {
|
||||
int32_t endType = this->ruleText.indexOf(gComma, pluralRuleStart);
|
||||
if (endType < 0) {
|
||||
|
@ -696,10 +696,10 @@ NFRule::doFormat(int64_t number, UnicodeString& toInsertInto, int32_t pos, UErro
|
|||
}
|
||||
else {
|
||||
pluralRuleStart = ruleText.indexOf(gDollarOpenParenthesis, -1, 0);
|
||||
int pluralRuleEnd = ruleText.indexOf(gClosedParenthesis, pluralRuleStart);
|
||||
int pluralRuleEnd = ruleText.indexOf(gClosedParenthesisDollar, -1, pluralRuleStart);
|
||||
int initialLength = toInsertInto.length();
|
||||
if (pluralRuleEnd < ruleText.length() - 1) {
|
||||
toInsertInto.insert(pos, ruleText.tempSubString(pluralRuleEnd + 1));
|
||||
toInsertInto.insert(pos, ruleText.tempSubString(pluralRuleEnd + 2));
|
||||
}
|
||||
toInsertInto.insert(pos,
|
||||
rulePatternFormat->format((int32_t)(number/uprv_pow(radix, exponent)), status));
|
||||
|
@ -742,10 +742,10 @@ NFRule::doFormat(double number, UnicodeString& toInsertInto, int32_t pos, UError
|
|||
}
|
||||
else {
|
||||
pluralRuleStart = ruleText.indexOf(gDollarOpenParenthesis, -1, 0);
|
||||
int pluralRuleEnd = ruleText.indexOf(gClosedParenthesis, pluralRuleStart);
|
||||
int pluralRuleEnd = ruleText.indexOf(gClosedParenthesisDollar, -1, pluralRuleStart);
|
||||
int initialLength = toInsertInto.length();
|
||||
if (pluralRuleEnd < ruleText.length() - 1) {
|
||||
toInsertInto.insert(pos, ruleText.tempSubString(pluralRuleEnd + 1));
|
||||
toInsertInto.insert(pos, ruleText.tempSubString(pluralRuleEnd + 2));
|
||||
}
|
||||
toInsertInto.insert(pos,
|
||||
rulePatternFormat->format((int32_t)(number/uprv_pow(radix, exponent)), status));
|
||||
|
@ -1400,7 +1400,7 @@ NFRule::findText(const UnicodeString& str,
|
|||
int start = position.getBeginIndex();
|
||||
if (start >= 0) {
|
||||
int32_t pluralRuleStart = ruleText.indexOf(gDollarOpenParenthesis, -1, 0);
|
||||
int32_t pluralRuleSuffix = ruleText.indexOf(gClosedParenthesis, pluralRuleStart) + 1;
|
||||
int32_t pluralRuleSuffix = ruleText.indexOf(gClosedParenthesisDollar, -1, pluralRuleStart) + 2;
|
||||
int32_t matchLen = position.getEndIndex() - start;
|
||||
UnicodeString prefix(ruleText.tempSubString(0, pluralRuleStart));
|
||||
UnicodeString suffix(ruleText.tempSubString(pluralRuleSuffix));
|
||||
|
|
|
@ -431,7 +431,7 @@ enum URBNFRuleSetTag {
|
|||
* <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
|
||||
|
@ -440,7 +440,7 @@ enum URBNFRuleSetTag {
|
|||
* 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
|
||||
|
|
|
@ -1961,7 +1961,7 @@ IntlTestRBNF::TestSetDecimalFormatSymbols() {
|
|||
|
||||
void IntlTestRBNF::TestPluralRules() {
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
UnicodeString enRules("%digits-ordinal:-x: −>>;0: =#,##0=$(ordinal,one{st}two{nd}few{rd}other{th});");
|
||||
UnicodeString enRules("%digits-ordinal:-x: −>>;0: =#,##0=$(ordinal,one{st}two{nd}few{rd}other{th})$;");
|
||||
UParseError parseError;
|
||||
RuleBasedNumberFormat enFormatter(enRules, Locale::getEnglish(), parseError, status);
|
||||
if (U_FAILURE(status)) {
|
||||
|
@ -2023,8 +2023,8 @@ void IntlTestRBNF::TestPluralRules() {
|
|||
"200: << hundred[ >>];"
|
||||
"300: << hundreds[ >>];"
|
||||
"500: << hundredss[ >>];"
|
||||
"1000: << $(cardinal,one{thousand}few{thousands}other{thousandss})[ >>];"
|
||||
"1000000: << $(cardinal,one{million}few{millions}other{millionss})[ >>];");
|
||||
"1000: << $(cardinal,one{thousand}few{thousands}other{thousandss})$[ >>];"
|
||||
"1000000: << $(cardinal,one{million}few{millions}other{millionss})$[ >>];");
|
||||
RuleBasedNumberFormat ruFormatter(ruRules, Locale("ru"), parseError, status);
|
||||
const char* const ruTestData[][2] = {
|
||||
{ "1", "one" },
|
||||
|
@ -2041,6 +2041,7 @@ void IntlTestRBNF::TestPluralRules() {
|
|||
{ "11,000", "eleven thousandss" },
|
||||
{ "21,000", "twenty-one thousand" },
|
||||
{ "22,000", "twenty-two thousands" },
|
||||
{ "25,001", "twenty-five thousandss one" },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue