ICU-1431 make default spellout rules use DecimalFormat, move former
defaults to en, remove greek rules (incomplete data). X-SVN-Rev: 6656
This commit is contained in:
parent
2cc65b1603
commit
3cdc9c6def
@ -5,8 +5,8 @@
|
||||
*******************************************************************************
|
||||
*
|
||||
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/dev/test/format/RbnfTest.java,v $
|
||||
* $Date: 2001/10/24 19:57:38 $
|
||||
* $Revision: 1.5 $
|
||||
* $Date: 2001/11/07 00:30:01 $
|
||||
* $Revision: 1.6 $
|
||||
*
|
||||
*****************************************************************************************
|
||||
*/
|
||||
@ -38,6 +38,55 @@ public class RbnfTest extends TestFmwk {
|
||||
}
|
||||
}
|
||||
|
||||
public void TestUndefinedSpellout() {
|
||||
Locale greek = new Locale("el", "", "");
|
||||
RuleBasedNumberFormat[] formatters = {
|
||||
new RuleBasedNumberFormat(greek, RuleBasedNumberFormat.SPELLOUT),
|
||||
new RuleBasedNumberFormat(greek, RuleBasedNumberFormat.ORDINAL),
|
||||
new RuleBasedNumberFormat(greek, RuleBasedNumberFormat.DURATION),
|
||||
};
|
||||
|
||||
String[] data = {
|
||||
"0",
|
||||
"1",
|
||||
"15",
|
||||
"20",
|
||||
"23",
|
||||
"73",
|
||||
"88",
|
||||
"100",
|
||||
"106",
|
||||
"127",
|
||||
"200",
|
||||
"579",
|
||||
"1,000",
|
||||
"2,000",
|
||||
"3,004",
|
||||
"4,567",
|
||||
"15,943",
|
||||
"105,000",
|
||||
"2,345,678",
|
||||
"-36",
|
||||
"-36.91215",
|
||||
"234.56789"
|
||||
};
|
||||
|
||||
NumberFormat decFormat = NumberFormat.getInstance(Locale.US);
|
||||
for (int j = 0; j < formatters.length; ++j) {
|
||||
com.ibm.text.NumberFormat formatter = formatters[j];
|
||||
logln("formatter[" + j + "]");
|
||||
for (int i = 0; i < data.length; ++i) {
|
||||
try {
|
||||
String result = formatter.format(decFormat.parse(data[i]));
|
||||
logln("[" + i + "] " + data[i] + " ==> " + result);
|
||||
}
|
||||
catch (Exception e) {
|
||||
errln("formatter[" + j + "], data[" + i + "] " + data[i] + " threw exception " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform a simple spot check on the English spellout rules
|
||||
*/
|
||||
|
@ -5,8 +5,8 @@
|
||||
*******************************************************************************
|
||||
*
|
||||
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/impl/data/Attic/NumberFormatRules.java,v $
|
||||
* $Date: 2000/03/10 04:07:27 $
|
||||
* $Revision: 1.2 $
|
||||
* $Date: 2001/11/07 00:30:31 $
|
||||
* $Revision: 1.3 $
|
||||
*
|
||||
*****************************************************************************************
|
||||
*/
|
||||
@ -21,7 +21,7 @@ import java.util.ListResourceBundle;
|
||||
* U.S. English data.
|
||||
*
|
||||
* @author Richard Gillam
|
||||
* @version $Version$ $Date: 2000/03/10 04:07:27 $
|
||||
* @version $Version$ $Date: 2001/11/07 00:30:31 $
|
||||
*/
|
||||
public class NumberFormatRules extends ListResourceBundle {
|
||||
/**
|
||||
@ -36,207 +36,17 @@ public class NumberFormatRules extends ListResourceBundle {
|
||||
|
||||
Object[][] contents = {
|
||||
/*
|
||||
* Spellout rules for U.S. English. This rule set has two variants:
|
||||
* %simplified is a set of rules showing the simple method of spelling
|
||||
* out numbers in English: 289 is formatted as "two hundred eighty-nine".
|
||||
* %default uses a more complicated algorithm to format
|
||||
* numbers in a more natural way: 289 is formatted as "two hundred AND
|
||||
* eighty-nine" and commas are inserted between the thousands groups for
|
||||
* values above 100,000.
|
||||
* Default used to be English (US) rules, but now default just formats
|
||||
* like DecimalFormat. The former default rules are now the _en rules.
|
||||
*/
|
||||
{ "SpelloutRules",
|
||||
// This rule set shows the normal simple formatting rules for English
|
||||
"%simplified:\n"
|
||||
// negative number rule. This rule is used to format negative
|
||||
// numbers. The result of formatting the number's absolute
|
||||
// value is placed where the >> is.
|
||||
+ " -x: minus >>;\n"
|
||||
// faction rule. This rule is used for formatting numbers
|
||||
// with fractional parts. The result of formatting the
|
||||
// number's integral part is substituted for the <<, and
|
||||
// the result of formatting the number's fractional part
|
||||
// (one digit at a time, e.g., 0.123 is "zero point one two
|
||||
// three") replaces the >>.
|
||||
+ " x.x: << point >>;\n"
|
||||
// the rules for the values from 0 to 19 are simply the
|
||||
// words for those numbers
|
||||
+ " zero; one; two; three; four; five; six; seven; eight; nine;\n"
|
||||
+ " ten; eleven; twelve; thirteen; fourteen; fifteen; sixteen;\n"
|
||||
+ " seventeen; eighteen; nineteen;\n"
|
||||
// beginning at 20, we use the >> to mark the position where
|
||||
// the result of formatting the number's ones digit. Thus,
|
||||
// we only need a new rule at every multiple of 10. Text in
|
||||
// backets is omitted if the value being formatted is an
|
||||
// even multiple of 10.
|
||||
+ " 20: twenty[->>];\n"
|
||||
+ " 30: thirty[->>];\n"
|
||||
+ " 40: forty[->>];\n"
|
||||
+ " 50: fifty[->>];\n"
|
||||
+ " 60: sixty[->>];\n"
|
||||
+ " 70: seventy[->>];\n"
|
||||
+ " 80: eighty[->>];\n"
|
||||
+ " 90: ninety[->>];\n"
|
||||
// beginning at 100, we can use << to mark the position where
|
||||
// the result of formatting the multiple of 100 is to be
|
||||
// inserted. Notice also that the meaning of >> has shifted:
|
||||
// here, it refers to both the ones place and the tens place.
|
||||
// The meanings of the << and >> tokens depend on the base value
|
||||
// of the rule. A rule's divisor is (usually) the highest
|
||||
// power of 10 that is less than or equal to the rule's base
|
||||
// value. The value being formatted is divided by the rule's
|
||||
// divisor, and the integral quotient is used to get the text
|
||||
// for <<, while the remainder is used to produce the text
|
||||
// for >>. Again, text in brackets is omitted if the value
|
||||
// being formatted is an even multiple of the rule's divisor
|
||||
// (in this case, an even multiple of 100)
|
||||
+ " 100: << hundred[ >>];\n"
|
||||
// The rules for the higher numbers work the same way as the
|
||||
// rule for 100: Again, the << and >> tokens depend on the
|
||||
// rule's divisor, which for all these rules is also the rule's
|
||||
// base value. To group by thousand, we simply don't have any
|
||||
// rules between 1,000 and 1,000,000.
|
||||
+ " 1000: << thousand[ >>];\n"
|
||||
+ " 1,000,000: << million[ >>];\n"
|
||||
+ " 1,000,000,000: << billion[ >>];\n"
|
||||
+ " 1,000,000,000,000: << trillion[ >>];\n"
|
||||
// overflow rule. This rule specifies that values of a
|
||||
// quadrillion or more are shown in numerals rather than words.
|
||||
// The == token means to format (with new rules) the value
|
||||
// being formatted by this rule and place the result where
|
||||
// the == is. The #,##0 inside the == signs is a
|
||||
// DecimalFormat pattern. It specifies that the value should
|
||||
// be formatted with a DecimalFormat object, and that it
|
||||
// should be formatted with no decimal places, at least one
|
||||
// digit, and a thousands separator.
|
||||
+ " 1,000,000,000,000,000: =#,##0=;\n"
|
||||
|
||||
// %default is a more elaborate form of %simplified; It is basically
|
||||
// the same, except that it introduces "and" before the ones digit
|
||||
// when appropriate (basically, between the tens and ones digits) and
|
||||
// separates the thousands groups with commas in values over 100,000.
|
||||
+ "%default:\n"
|
||||
// negative-number and fraction rules. These are the same
|
||||
// as those for %simplified, but ave to be stated here too
|
||||
// because this is an entry point
|
||||
+ " -x: minus >>;\n"
|
||||
+ " x.x: << point >>;\n"
|
||||
// just use %simplified for values below 100
|
||||
+ " =%simplified=;\n"
|
||||
// for values from 100 to 9,999 use %%and to decide whether or
|
||||
// not to interpose the "and"
|
||||
+ " 100: << hundred[ >%%and>];\n"
|
||||
+ " 1000: << thousand[ >%%and>];\n"
|
||||
// for values of 100,000 and up, use %%commas to interpose the
|
||||
// commas in the right places (and also to interpose the "and")
|
||||
+ " 100,000>>: << thousand[>%%commas>];\n"
|
||||
+ " 1,000,000: << million[>%%commas>];\n"
|
||||
+ " 1,000,000,000: << billion[>%%commas>];\n"
|
||||
+ " 1,000,000,000,000: << trillion[>%%commas>];\n"
|
||||
+ " 1,000,000,000,000,000: =#,##0=;\n"
|
||||
// if the value passed to this rule set is greater than 100, don't
|
||||
// add the "and"; if it's less than 100, add "and" before the last
|
||||
// digits
|
||||
+ "%%and:\n"
|
||||
+ " and =%default=;\n"
|
||||
+ " 100: =%default=;\n"
|
||||
// this rule set is used to place the commas
|
||||
+ "%%commas:\n"
|
||||
// for values below 100, add "and" (the apostrophe at the
|
||||
// beginning is ignored, but causes the space that follows it
|
||||
// to be significant: this is necessary because the rules
|
||||
// calling %%commas don't put a space before it)
|
||||
+ " ' and =%default=;\n"
|
||||
// put a comma after the thousands (or whatever preceded the
|
||||
// hundreds)
|
||||
+ " 100: , =%default=;\n"
|
||||
// put a comma after the millions (or whatever precedes the
|
||||
// thousands)
|
||||
+ " 1000: , <%default< thousand, >%default>;\n"
|
||||
// and so on...
|
||||
+ " 1,000,000: , =%default=;"
|
||||
// %%lenient-parse isn't really a set of number formatting rules;
|
||||
// it's a set of collation rules. Lenient-parse mode uses a Collator
|
||||
// object to compare fragments of the text being parsed to the text
|
||||
// in the rules, allowing more leeway in the matching text. This set
|
||||
// of rules tells the formatter to ignore commas when parsing (it
|
||||
// already ignores spaces, which is why we refer to the space; it also
|
||||
// ignores hyphens, making "twenty one" and "twenty-one" parse
|
||||
// identically)
|
||||
+ "%%lenient-parse:\n"
|
||||
+ " & ' ' , ',' ;\n" },
|
||||
|
||||
/*
|
||||
* This rule set adds an English ordinal abbreviation to the end of a
|
||||
* number. For example, 2 is formatted as "2nd". Parsing doesn't work with
|
||||
* this rule set. To parse, use DecimalFormat on the numeral.
|
||||
*/
|
||||
"=#,##0.######=;\n"
|
||||
},
|
||||
{ "OrdinalRules",
|
||||
// this rule set formats the numeral and calls %%abbrev to
|
||||
// supply the abbreviation
|
||||
"%main:\n"
|
||||
+ " =#,##0==%%abbrev=;\n"
|
||||
// this rule set supplies the abbreviation
|
||||
+ "%%abbrev:\n"
|
||||
// the abbreviations. Everything from 4 to 19 ends in "th"
|
||||
+ " th; st; nd; rd; th;\n"
|
||||
// at 20, we begin repeating the cycle every 10 (13 is "13th",
|
||||
// but 23 and 33 are "23rd" and "33rd") We do this by
|
||||
// ignoring all bug the ones digit in selecting the abbreviation
|
||||
+ " 20: >>;\n"
|
||||
// at 100, we repeat the whole cycle by considering only the
|
||||
// tens and ones digits in picking an abbreviation
|
||||
+ " 100: >>;\n" },
|
||||
|
||||
/*
|
||||
* This rule set formats a number of seconds in sexagesimal notation
|
||||
* (i.e., hours, minutes, and seconds). %with-words formats it with
|
||||
* words (3,740 is "1 hour, 2 minutes, 20 seconds") and %in-numerals
|
||||
* formats it entirely in numerals (3,740 is "1:02:20").
|
||||
*/
|
||||
"=#,##0=;\n"
|
||||
},
|
||||
{ "DurationRules",
|
||||
// main rule set for formatting with words
|
||||
"%with-words:\n"
|
||||
// take care of singular and plural forms of "second"
|
||||
+ " 0 seconds; 1 second; =0= seconds;\n"
|
||||
// use %%min to format values greater than 60 seconds
|
||||
+ " 60/60: <%%min<[, >>];\n"
|
||||
// use %%hr to format values greater than 3,600 seconds
|
||||
// (the ">>>" below causes us to see the number of minutes
|
||||
// when when there are zero minutes)
|
||||
+ " 3600/60: <%%hr<[, >>>];\n"
|
||||
// this rule set takes care of the singular and plural forms
|
||||
// of "minute"
|
||||
+ "%%min:\n"
|
||||
+ " 0 minutes; 1 minute; =0= minutes;\n"
|
||||
// this rule set takes care of the singular and plural forms
|
||||
// of "hour"
|
||||
+ "%%hr:\n"
|
||||
+ " 0 hours; 1 hour; =0= hours;\n"
|
||||
|
||||
// main rule set for formatting in numerals
|
||||
+ "%in-numerals:\n"
|
||||
// values below 60 seconds are shown with "sec."
|
||||
+ " =0= sec.;\n"
|
||||
// higher values are shown with colons: %%min-sec is used for
|
||||
// values below 3,600 seconds...
|
||||
+ " 60: =%%min-sec=;\n"
|
||||
// ...and %%hr-min-sec is used for values of 3,600 seconds
|
||||
// and above
|
||||
+ " 3600: =%%hr-min-sec=;\n"
|
||||
// this rule causes values of less than 10 minutes to show without
|
||||
// a leading zero
|
||||
+ "%%min-sec:\n"
|
||||
+ " 0: :=00=;\n"
|
||||
+ " 60/60: <0<>>;\n"
|
||||
// this rule set is used for values of 3,600 or more. Minutes are always
|
||||
// shown, and always shown with two digits
|
||||
+ "%%hr-min-sec:\n"
|
||||
+ " 0: :=00=;\n"
|
||||
+ " 60/60: <00<>>;\n"
|
||||
+ " 3600/60: <#,##0<:>>>;\n"
|
||||
// the lenient-parse rules allow several different characters to be used
|
||||
// as delimiters between hours, minutes, and seconds
|
||||
+ "%%lenient-parse:\n"
|
||||
+ " & ':' = '.' = ' ' = '-';\n" }
|
||||
"=#,##0=;\n"
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -5,8 +5,8 @@
|
||||
*******************************************************************************
|
||||
*
|
||||
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/impl/data/Attic/NumberFormatRules_en.java,v $
|
||||
* $Date: 2000/03/10 04:07:27 $
|
||||
* $Revision: 1.2 $
|
||||
* $Date: 2001/11/07 00:30:32 $
|
||||
* $Revision: 1.3 $
|
||||
*
|
||||
*****************************************************************************************
|
||||
*/
|
||||
@ -20,7 +20,7 @@ import java.util.ListResourceBundle;
|
||||
* inherits everything from the default.
|
||||
*
|
||||
* @author Richard Gillam
|
||||
* @version $Version$ $Date: 2000/03/10 04:07:27 $
|
||||
* @version $Version$ $Date: 2001/11/07 00:30:32 $
|
||||
*/
|
||||
public class NumberFormatRules_en extends ListResourceBundle {
|
||||
/**
|
||||
@ -33,16 +33,43 @@ public class NumberFormatRules_en extends ListResourceBundle {
|
||||
return contents;
|
||||
}
|
||||
|
||||
// this is exactly the same as SpelloutRules from the root resource
|
||||
// bundle
|
||||
// This used to be the root rules, but they are English-specific, so for
|
||||
// now we just don't have any interesting rules for the root. This includes
|
||||
// the comments that used to be in the root rules.
|
||||
Object[][] contents = {
|
||||
/*
|
||||
* Spellout rules for U.S. English. This rule set has two variants:
|
||||
* %simplified is a set of rules showing the simple method of spelling
|
||||
* out numbers in English: 289 is formatted as "two hundred eighty-nine".
|
||||
* %default uses a more complicated algorithm to format
|
||||
* numbers in a more natural way: 289 is formatted as "two hundred AND
|
||||
* eighty-nine" and commas are inserted between the thousands groups for
|
||||
* values above 100,000.
|
||||
*/
|
||||
{ "SpelloutRules",
|
||||
// This rule set shows the normal simple formatting rules for English
|
||||
"%simplified:\n"
|
||||
// negative number rule. This rule is used to format negative
|
||||
// numbers. The result of formatting the number's absolute
|
||||
// value is placed where the >> is.
|
||||
+ " -x: minus >>;\n"
|
||||
// faction rule. This rule is used for formatting numbers
|
||||
// with fractional parts. The result of formatting the
|
||||
// number's integral part is substituted for the <<, and
|
||||
// the result of formatting the number's fractional part
|
||||
// (one digit at a time, e.g., 0.123 is "zero point one two
|
||||
// three") replaces the >>.
|
||||
+ " x.x: << point >>;\n"
|
||||
// the rules for the values from 0 to 19 are simply the
|
||||
// words for those numbers
|
||||
+ " zero; one; two; three; four; five; six; seven; eight; nine;\n"
|
||||
+ " ten; eleven; twelve; thirteen; fourteen; fifteen; sixteen;\n"
|
||||
+ " seventeen; eighteen; nineteen;\n"
|
||||
// beginning at 20, we use the >> to mark the position where
|
||||
// the result of formatting the number's ones digit. Thus,
|
||||
// we only need a new rule at every multiple of 10. Text in
|
||||
// backets is omitted if the value being formatted is an
|
||||
// even multiple of 10.
|
||||
+ " 20: twenty[->>];\n"
|
||||
+ " 30: thirty[->>];\n"
|
||||
+ " 40: forty[->>];\n"
|
||||
@ -51,32 +78,167 @@ public class NumberFormatRules_en extends ListResourceBundle {
|
||||
+ " 70: seventy[->>];\n"
|
||||
+ " 80: eighty[->>];\n"
|
||||
+ " 90: ninety[->>];\n"
|
||||
// beginning at 100, we can use << to mark the position where
|
||||
// the result of formatting the multiple of 100 is to be
|
||||
// inserted. Notice also that the meaning of >> has shifted:
|
||||
// here, it refers to both the ones place and the tens place.
|
||||
// The meanings of the << and >> tokens depend on the base value
|
||||
// of the rule. A rule's divisor is (usually) the highest
|
||||
// power of 10 that is less than or equal to the rule's base
|
||||
// value. The value being formatted is divided by the rule's
|
||||
// divisor, and the integral quotient is used to get the text
|
||||
// for <<, while the remainder is used to produce the text
|
||||
// for >>. Again, text in brackets is omitted if the value
|
||||
// being formatted is an even multiple of the rule's divisor
|
||||
// (in this case, an even multiple of 100)
|
||||
+ " 100: << hundred[ >>];\n"
|
||||
// The rules for the higher numbers work the same way as the
|
||||
// rule for 100: Again, the << and >> tokens depend on the
|
||||
// rule's divisor, which for all these rules is also the rule's
|
||||
// base value. To group by thousand, we simply don't have any
|
||||
// rules between 1,000 and 1,000,000.
|
||||
+ " 1000: << thousand[ >>];\n"
|
||||
+ " 1,000,000: << million[ >>];\n"
|
||||
+ " 1,000,000,000: << billion[ >>];\n"
|
||||
+ " 1,000,000,000,000: << trillion[ >>];\n"
|
||||
// overflow rule. This rule specifies that values of a
|
||||
// quadrillion or more are shown in numerals rather than words.
|
||||
// The == token means to format (with new rules) the value
|
||||
// being formatted by this rule and place the result where
|
||||
// the == is. The #,##0 inside the == signs is a
|
||||
// DecimalFormat pattern. It specifies that the value should
|
||||
// be formatted with a DecimalFormat object, and that it
|
||||
// should be formatted with no decimal places, at least one
|
||||
// digit, and a thousands separator.
|
||||
+ " 1,000,000,000,000,000: =#,##0=;\n"
|
||||
|
||||
// %default is a more elaborate form of %simplified; It is basically
|
||||
// the same, except that it introduces "and" before the ones digit
|
||||
// when appropriate (basically, between the tens and ones digits) and
|
||||
// separates the thousands groups with commas in values over 100,000.
|
||||
+ "%default:\n"
|
||||
// negative-number and fraction rules. These are the same
|
||||
// as those for %simplified, but ave to be stated here too
|
||||
// because this is an entry point
|
||||
+ " -x: minus >>;\n"
|
||||
+ " x.x: << point >>;\n"
|
||||
// just use %simplified for values below 100
|
||||
+ " =%simplified=;\n"
|
||||
// for values from 100 to 9,999 use %%and to decide whether or
|
||||
// not to interpose the "and"
|
||||
+ " 100: << hundred[ >%%and>];\n"
|
||||
+ " 1000: << thousand[ >%%and>];\n"
|
||||
// for values of 100,000 and up, use %%commas to interpose the
|
||||
// commas in the right places (and also to interpose the "and")
|
||||
+ " 100,000>>: << thousand[>%%commas>];\n"
|
||||
+ " 1,000,000: << million[>%%commas>];\n"
|
||||
+ " 1,000,000,000: << billion[>%%commas>];\n"
|
||||
+ " 1,000,000,000,000: << trillion[>%%commas>];\n"
|
||||
+ " 1,000,000,000,000,000: =#,##0=;\n"
|
||||
// if the value passed to this rule set is greater than 100, don't
|
||||
// add the "and"; if it's less than 100, add "and" before the last
|
||||
// digits
|
||||
+ "%%and:\n"
|
||||
+ " and =%default=;\n"
|
||||
+ " 100: =%default=;\n"
|
||||
// this rule set is used to place the commas
|
||||
+ "%%commas:\n"
|
||||
// for values below 100, add "and" (the apostrophe at the
|
||||
// beginning is ignored, but causes the space that follows it
|
||||
// to be significant: this is necessary because the rules
|
||||
// calling %%commas don't put a space before it)
|
||||
+ " ' and =%default=;\n"
|
||||
// put a comma after the thousands (or whatever preceded the
|
||||
// hundreds)
|
||||
+ " 100: , =%default=;\n"
|
||||
// put a comma after the millions (or whatever precedes the
|
||||
// thousands)
|
||||
+ " 1000: , <%default< thousand, >%default>;\n"
|
||||
// and so on...
|
||||
+ " 1,000,000: , =%default=;"
|
||||
// %%lenient-parse isn't really a set of number formatting rules;
|
||||
// it's a set of collation rules. Lenient-parse mode uses a Collator
|
||||
// object to compare fragments of the text being parsed to the text
|
||||
// in the rules, allowing more leeway in the matching text. This set
|
||||
// of rules tells the formatter to ignore commas when parsing (it
|
||||
// already ignores spaces, which is why we refer to the space; it also
|
||||
// ignores hyphens, making "twenty one" and "twenty-one" parse
|
||||
// identically)
|
||||
+ "%%lenient-parse:\n"
|
||||
+ " & ' ' , ',' ;\n" }
|
||||
+ " & ' ' , ',' ;\n" },
|
||||
|
||||
/*
|
||||
* This rule set adds an English ordinal abbreviation to the end of a
|
||||
* number. For example, 2 is formatted as "2nd". Parsing doesn't work with
|
||||
* this rule set. To parse, use DecimalFormat on the numeral.
|
||||
*/
|
||||
{ "OrdinalRules",
|
||||
// this rule set formats the numeral and calls %%abbrev to
|
||||
// supply the abbreviation
|
||||
"%main:\n"
|
||||
+ " =#,##0==%%abbrev=;\n"
|
||||
// this rule set supplies the abbreviation
|
||||
+ "%%abbrev:\n"
|
||||
// the abbreviations. Everything from 4 to 19 ends in "th"
|
||||
+ " th; st; nd; rd; th;\n"
|
||||
// at 20, we begin repeating the cycle every 10 (13 is "13th",
|
||||
// but 23 and 33 are "23rd" and "33rd") We do this by
|
||||
// ignoring all bug the ones digit in selecting the abbreviation
|
||||
+ " 20: >>;\n"
|
||||
// at 100, we repeat the whole cycle by considering only the
|
||||
// tens and ones digits in picking an abbreviation
|
||||
+ " 100: >>;\n" },
|
||||
|
||||
/*
|
||||
* This rule set formats a number of seconds in sexagesimal notation
|
||||
* (i.e., hours, minutes, and seconds). %with-words formats it with
|
||||
* words (3,740 is "1 hour, 2 minutes, 20 seconds") and %in-numerals
|
||||
* formats it entirely in numerals (3,740 is "1:02:20").
|
||||
*/
|
||||
{ "DurationRules",
|
||||
// main rule set for formatting with words
|
||||
"%with-words:\n"
|
||||
// take care of singular and plural forms of "second"
|
||||
+ " 0 seconds; 1 second; =0= seconds;\n"
|
||||
// use %%min to format values greater than 60 seconds
|
||||
+ " 60/60: <%%min<[, >>];\n"
|
||||
// use %%hr to format values greater than 3,600 seconds
|
||||
// (the ">>>" below causes us to see the number of minutes
|
||||
// when when there are zero minutes)
|
||||
+ " 3600/60: <%%hr<[, >>>];\n"
|
||||
// this rule set takes care of the singular and plural forms
|
||||
// of "minute"
|
||||
+ "%%min:\n"
|
||||
+ " 0 minutes; 1 minute; =0= minutes;\n"
|
||||
// this rule set takes care of the singular and plural forms
|
||||
// of "hour"
|
||||
+ "%%hr:\n"
|
||||
+ " 0 hours; 1 hour; =0= hours;\n"
|
||||
|
||||
// main rule set for formatting in numerals
|
||||
+ "%in-numerals:\n"
|
||||
// values below 60 seconds are shown with "sec."
|
||||
+ " =0= sec.;\n"
|
||||
// higher values are shown with colons: %%min-sec is used for
|
||||
// values below 3,600 seconds...
|
||||
+ " 60: =%%min-sec=;\n"
|
||||
// ...and %%hr-min-sec is used for values of 3,600 seconds
|
||||
// and above
|
||||
+ " 3600: =%%hr-min-sec=;\n"
|
||||
// this rule causes values of less than 10 minutes to show without
|
||||
// a leading zero
|
||||
+ "%%min-sec:\n"
|
||||
+ " 0: :=00=;\n"
|
||||
+ " 60/60: <0<>>;\n"
|
||||
// this rule set is used for values of 3,600 or more. Minutes are always
|
||||
// shown, and always shown with two digits
|
||||
+ "%%hr-min-sec:\n"
|
||||
+ " 0: :=00=;\n"
|
||||
+ " 60/60: <00<>>;\n"
|
||||
+ " 3600/60: <#,##0<:>>>;\n"
|
||||
// the lenient-parse rules allow several different characters to be used
|
||||
// as delimiters between hours, minutes, and seconds
|
||||
+ "%%lenient-parse:\n"
|
||||
+ " & ':' = '.' = ' ' = '-';\n" }
|
||||
};
|
||||
}
|
||||
|
@ -5,8 +5,8 @@
|
||||
*******************************************************************************
|
||||
*
|
||||
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/test/rbnf/Attic/RbnfTest.java,v $
|
||||
* $Date: 2001/10/24 19:57:38 $
|
||||
* $Revision: 1.5 $
|
||||
* $Date: 2001/11/07 00:30:01 $
|
||||
* $Revision: 1.6 $
|
||||
*
|
||||
*****************************************************************************************
|
||||
*/
|
||||
@ -38,6 +38,55 @@ public class RbnfTest extends TestFmwk {
|
||||
}
|
||||
}
|
||||
|
||||
public void TestUndefinedSpellout() {
|
||||
Locale greek = new Locale("el", "", "");
|
||||
RuleBasedNumberFormat[] formatters = {
|
||||
new RuleBasedNumberFormat(greek, RuleBasedNumberFormat.SPELLOUT),
|
||||
new RuleBasedNumberFormat(greek, RuleBasedNumberFormat.ORDINAL),
|
||||
new RuleBasedNumberFormat(greek, RuleBasedNumberFormat.DURATION),
|
||||
};
|
||||
|
||||
String[] data = {
|
||||
"0",
|
||||
"1",
|
||||
"15",
|
||||
"20",
|
||||
"23",
|
||||
"73",
|
||||
"88",
|
||||
"100",
|
||||
"106",
|
||||
"127",
|
||||
"200",
|
||||
"579",
|
||||
"1,000",
|
||||
"2,000",
|
||||
"3,004",
|
||||
"4,567",
|
||||
"15,943",
|
||||
"105,000",
|
||||
"2,345,678",
|
||||
"-36",
|
||||
"-36.91215",
|
||||
"234.56789"
|
||||
};
|
||||
|
||||
NumberFormat decFormat = NumberFormat.getInstance(Locale.US);
|
||||
for (int j = 0; j < formatters.length; ++j) {
|
||||
com.ibm.text.NumberFormat formatter = formatters[j];
|
||||
logln("formatter[" + j + "]");
|
||||
for (int i = 0; i < data.length; ++i) {
|
||||
try {
|
||||
String result = formatter.format(decFormat.parse(data[i]));
|
||||
logln("[" + i + "] " + data[i] + " ==> " + result);
|
||||
}
|
||||
catch (Exception e) {
|
||||
errln("formatter[" + j + "], data[" + i + "] " + data[i] + " threw exception " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform a simple spot check on the English spellout rules
|
||||
*/
|
||||
|
@ -5,8 +5,8 @@
|
||||
*******************************************************************************
|
||||
*
|
||||
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/text/resources/Attic/NumberFormatRules.java,v $
|
||||
* $Date: 2000/03/10 04:07:27 $
|
||||
* $Revision: 1.2 $
|
||||
* $Date: 2001/11/07 00:30:31 $
|
||||
* $Revision: 1.3 $
|
||||
*
|
||||
*****************************************************************************************
|
||||
*/
|
||||
@ -21,7 +21,7 @@ import java.util.ListResourceBundle;
|
||||
* U.S. English data.
|
||||
*
|
||||
* @author Richard Gillam
|
||||
* @version $Version$ $Date: 2000/03/10 04:07:27 $
|
||||
* @version $Version$ $Date: 2001/11/07 00:30:31 $
|
||||
*/
|
||||
public class NumberFormatRules extends ListResourceBundle {
|
||||
/**
|
||||
@ -36,207 +36,17 @@ public class NumberFormatRules extends ListResourceBundle {
|
||||
|
||||
Object[][] contents = {
|
||||
/*
|
||||
* Spellout rules for U.S. English. This rule set has two variants:
|
||||
* %simplified is a set of rules showing the simple method of spelling
|
||||
* out numbers in English: 289 is formatted as "two hundred eighty-nine".
|
||||
* %default uses a more complicated algorithm to format
|
||||
* numbers in a more natural way: 289 is formatted as "two hundred AND
|
||||
* eighty-nine" and commas are inserted between the thousands groups for
|
||||
* values above 100,000.
|
||||
* Default used to be English (US) rules, but now default just formats
|
||||
* like DecimalFormat. The former default rules are now the _en rules.
|
||||
*/
|
||||
{ "SpelloutRules",
|
||||
// This rule set shows the normal simple formatting rules for English
|
||||
"%simplified:\n"
|
||||
// negative number rule. This rule is used to format negative
|
||||
// numbers. The result of formatting the number's absolute
|
||||
// value is placed where the >> is.
|
||||
+ " -x: minus >>;\n"
|
||||
// faction rule. This rule is used for formatting numbers
|
||||
// with fractional parts. The result of formatting the
|
||||
// number's integral part is substituted for the <<, and
|
||||
// the result of formatting the number's fractional part
|
||||
// (one digit at a time, e.g., 0.123 is "zero point one two
|
||||
// three") replaces the >>.
|
||||
+ " x.x: << point >>;\n"
|
||||
// the rules for the values from 0 to 19 are simply the
|
||||
// words for those numbers
|
||||
+ " zero; one; two; three; four; five; six; seven; eight; nine;\n"
|
||||
+ " ten; eleven; twelve; thirteen; fourteen; fifteen; sixteen;\n"
|
||||
+ " seventeen; eighteen; nineteen;\n"
|
||||
// beginning at 20, we use the >> to mark the position where
|
||||
// the result of formatting the number's ones digit. Thus,
|
||||
// we only need a new rule at every multiple of 10. Text in
|
||||
// backets is omitted if the value being formatted is an
|
||||
// even multiple of 10.
|
||||
+ " 20: twenty[->>];\n"
|
||||
+ " 30: thirty[->>];\n"
|
||||
+ " 40: forty[->>];\n"
|
||||
+ " 50: fifty[->>];\n"
|
||||
+ " 60: sixty[->>];\n"
|
||||
+ " 70: seventy[->>];\n"
|
||||
+ " 80: eighty[->>];\n"
|
||||
+ " 90: ninety[->>];\n"
|
||||
// beginning at 100, we can use << to mark the position where
|
||||
// the result of formatting the multiple of 100 is to be
|
||||
// inserted. Notice also that the meaning of >> has shifted:
|
||||
// here, it refers to both the ones place and the tens place.
|
||||
// The meanings of the << and >> tokens depend on the base value
|
||||
// of the rule. A rule's divisor is (usually) the highest
|
||||
// power of 10 that is less than or equal to the rule's base
|
||||
// value. The value being formatted is divided by the rule's
|
||||
// divisor, and the integral quotient is used to get the text
|
||||
// for <<, while the remainder is used to produce the text
|
||||
// for >>. Again, text in brackets is omitted if the value
|
||||
// being formatted is an even multiple of the rule's divisor
|
||||
// (in this case, an even multiple of 100)
|
||||
+ " 100: << hundred[ >>];\n"
|
||||
// The rules for the higher numbers work the same way as the
|
||||
// rule for 100: Again, the << and >> tokens depend on the
|
||||
// rule's divisor, which for all these rules is also the rule's
|
||||
// base value. To group by thousand, we simply don't have any
|
||||
// rules between 1,000 and 1,000,000.
|
||||
+ " 1000: << thousand[ >>];\n"
|
||||
+ " 1,000,000: << million[ >>];\n"
|
||||
+ " 1,000,000,000: << billion[ >>];\n"
|
||||
+ " 1,000,000,000,000: << trillion[ >>];\n"
|
||||
// overflow rule. This rule specifies that values of a
|
||||
// quadrillion or more are shown in numerals rather than words.
|
||||
// The == token means to format (with new rules) the value
|
||||
// being formatted by this rule and place the result where
|
||||
// the == is. The #,##0 inside the == signs is a
|
||||
// DecimalFormat pattern. It specifies that the value should
|
||||
// be formatted with a DecimalFormat object, and that it
|
||||
// should be formatted with no decimal places, at least one
|
||||
// digit, and a thousands separator.
|
||||
+ " 1,000,000,000,000,000: =#,##0=;\n"
|
||||
|
||||
// %default is a more elaborate form of %simplified; It is basically
|
||||
// the same, except that it introduces "and" before the ones digit
|
||||
// when appropriate (basically, between the tens and ones digits) and
|
||||
// separates the thousands groups with commas in values over 100,000.
|
||||
+ "%default:\n"
|
||||
// negative-number and fraction rules. These are the same
|
||||
// as those for %simplified, but ave to be stated here too
|
||||
// because this is an entry point
|
||||
+ " -x: minus >>;\n"
|
||||
+ " x.x: << point >>;\n"
|
||||
// just use %simplified for values below 100
|
||||
+ " =%simplified=;\n"
|
||||
// for values from 100 to 9,999 use %%and to decide whether or
|
||||
// not to interpose the "and"
|
||||
+ " 100: << hundred[ >%%and>];\n"
|
||||
+ " 1000: << thousand[ >%%and>];\n"
|
||||
// for values of 100,000 and up, use %%commas to interpose the
|
||||
// commas in the right places (and also to interpose the "and")
|
||||
+ " 100,000>>: << thousand[>%%commas>];\n"
|
||||
+ " 1,000,000: << million[>%%commas>];\n"
|
||||
+ " 1,000,000,000: << billion[>%%commas>];\n"
|
||||
+ " 1,000,000,000,000: << trillion[>%%commas>];\n"
|
||||
+ " 1,000,000,000,000,000: =#,##0=;\n"
|
||||
// if the value passed to this rule set is greater than 100, don't
|
||||
// add the "and"; if it's less than 100, add "and" before the last
|
||||
// digits
|
||||
+ "%%and:\n"
|
||||
+ " and =%default=;\n"
|
||||
+ " 100: =%default=;\n"
|
||||
// this rule set is used to place the commas
|
||||
+ "%%commas:\n"
|
||||
// for values below 100, add "and" (the apostrophe at the
|
||||
// beginning is ignored, but causes the space that follows it
|
||||
// to be significant: this is necessary because the rules
|
||||
// calling %%commas don't put a space before it)
|
||||
+ " ' and =%default=;\n"
|
||||
// put a comma after the thousands (or whatever preceded the
|
||||
// hundreds)
|
||||
+ " 100: , =%default=;\n"
|
||||
// put a comma after the millions (or whatever precedes the
|
||||
// thousands)
|
||||
+ " 1000: , <%default< thousand, >%default>;\n"
|
||||
// and so on...
|
||||
+ " 1,000,000: , =%default=;"
|
||||
// %%lenient-parse isn't really a set of number formatting rules;
|
||||
// it's a set of collation rules. Lenient-parse mode uses a Collator
|
||||
// object to compare fragments of the text being parsed to the text
|
||||
// in the rules, allowing more leeway in the matching text. This set
|
||||
// of rules tells the formatter to ignore commas when parsing (it
|
||||
// already ignores spaces, which is why we refer to the space; it also
|
||||
// ignores hyphens, making "twenty one" and "twenty-one" parse
|
||||
// identically)
|
||||
+ "%%lenient-parse:\n"
|
||||
+ " & ' ' , ',' ;\n" },
|
||||
|
||||
/*
|
||||
* This rule set adds an English ordinal abbreviation to the end of a
|
||||
* number. For example, 2 is formatted as "2nd". Parsing doesn't work with
|
||||
* this rule set. To parse, use DecimalFormat on the numeral.
|
||||
*/
|
||||
"=#,##0.######=;\n"
|
||||
},
|
||||
{ "OrdinalRules",
|
||||
// this rule set formats the numeral and calls %%abbrev to
|
||||
// supply the abbreviation
|
||||
"%main:\n"
|
||||
+ " =#,##0==%%abbrev=;\n"
|
||||
// this rule set supplies the abbreviation
|
||||
+ "%%abbrev:\n"
|
||||
// the abbreviations. Everything from 4 to 19 ends in "th"
|
||||
+ " th; st; nd; rd; th;\n"
|
||||
// at 20, we begin repeating the cycle every 10 (13 is "13th",
|
||||
// but 23 and 33 are "23rd" and "33rd") We do this by
|
||||
// ignoring all bug the ones digit in selecting the abbreviation
|
||||
+ " 20: >>;\n"
|
||||
// at 100, we repeat the whole cycle by considering only the
|
||||
// tens and ones digits in picking an abbreviation
|
||||
+ " 100: >>;\n" },
|
||||
|
||||
/*
|
||||
* This rule set formats a number of seconds in sexagesimal notation
|
||||
* (i.e., hours, minutes, and seconds). %with-words formats it with
|
||||
* words (3,740 is "1 hour, 2 minutes, 20 seconds") and %in-numerals
|
||||
* formats it entirely in numerals (3,740 is "1:02:20").
|
||||
*/
|
||||
"=#,##0=;\n"
|
||||
},
|
||||
{ "DurationRules",
|
||||
// main rule set for formatting with words
|
||||
"%with-words:\n"
|
||||
// take care of singular and plural forms of "second"
|
||||
+ " 0 seconds; 1 second; =0= seconds;\n"
|
||||
// use %%min to format values greater than 60 seconds
|
||||
+ " 60/60: <%%min<[, >>];\n"
|
||||
// use %%hr to format values greater than 3,600 seconds
|
||||
// (the ">>>" below causes us to see the number of minutes
|
||||
// when when there are zero minutes)
|
||||
+ " 3600/60: <%%hr<[, >>>];\n"
|
||||
// this rule set takes care of the singular and plural forms
|
||||
// of "minute"
|
||||
+ "%%min:\n"
|
||||
+ " 0 minutes; 1 minute; =0= minutes;\n"
|
||||
// this rule set takes care of the singular and plural forms
|
||||
// of "hour"
|
||||
+ "%%hr:\n"
|
||||
+ " 0 hours; 1 hour; =0= hours;\n"
|
||||
|
||||
// main rule set for formatting in numerals
|
||||
+ "%in-numerals:\n"
|
||||
// values below 60 seconds are shown with "sec."
|
||||
+ " =0= sec.;\n"
|
||||
// higher values are shown with colons: %%min-sec is used for
|
||||
// values below 3,600 seconds...
|
||||
+ " 60: =%%min-sec=;\n"
|
||||
// ...and %%hr-min-sec is used for values of 3,600 seconds
|
||||
// and above
|
||||
+ " 3600: =%%hr-min-sec=;\n"
|
||||
// this rule causes values of less than 10 minutes to show without
|
||||
// a leading zero
|
||||
+ "%%min-sec:\n"
|
||||
+ " 0: :=00=;\n"
|
||||
+ " 60/60: <0<>>;\n"
|
||||
// this rule set is used for values of 3,600 or more. Minutes are always
|
||||
// shown, and always shown with two digits
|
||||
+ "%%hr-min-sec:\n"
|
||||
+ " 0: :=00=;\n"
|
||||
+ " 60/60: <00<>>;\n"
|
||||
+ " 3600/60: <#,##0<:>>>;\n"
|
||||
// the lenient-parse rules allow several different characters to be used
|
||||
// as delimiters between hours, minutes, and seconds
|
||||
+ "%%lenient-parse:\n"
|
||||
+ " & ':' = '.' = ' ' = '-';\n" }
|
||||
"=#,##0=;\n"
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -1,80 +0,0 @@
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2000, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*
|
||||
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/text/resources/Attic/NumberFormatRules_el.java,v $
|
||||
* $Date: 2000/03/10 04:07:27 $
|
||||
* $Revision: 1.2 $
|
||||
*
|
||||
*****************************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.text.resources;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
/**
|
||||
* RuleBasedNumberFormat data for Greek
|
||||
*
|
||||
* @author Richard Gillam
|
||||
* @version $Version$ $Date: 2000/03/10 04:07:27 $
|
||||
*/
|
||||
public class NumberFormatRules_el extends ListResourceBundle {
|
||||
/**
|
||||
* Puts a copyright in the .class file
|
||||
*/
|
||||
private static final String copyrightNotice
|
||||
= "Copyright \u00a91997-1998 IBM Corp. All rights reserved.";
|
||||
|
||||
public Object[][] getContents() {
|
||||
return contents;
|
||||
}
|
||||
|
||||
Object[][] contents = {
|
||||
/**
|
||||
* Spellout rules for Greek. Again in Greek we have to supply the words
|
||||
* for the multiples of 100 because they can't be derived algorithmically.
|
||||
* Also, the tens dgit changes form when followed by a ones digit: an
|
||||
* accent mark disappears from the tens digit and moves to the ones digit.
|
||||
* Therefore, instead of using the [] notation, we actually have to use
|
||||
* two separate rules for each multiple of 10 to show the two forms of
|
||||
* the word.
|
||||
*/
|
||||
{ "SpelloutRules",
|
||||
"zero (incomplete data); \u03ad\u03bd\u03b1; \u03b4\u03cd\u03bf; \u03b4\u03c1\u03af\u03b1; "
|
||||
+ "\u03c4\u03ad\u03c3\u03c3\u03b5\u03c1\u03b1; \u03c0\u03ad\u03bd\u03c4\u03b5; "
|
||||
+ "\u03ad\u03be\u03b9; \u03b5\u03c0\u03c4\u03ac; \u03bf\u03ba\u03c4\u03ce; "
|
||||
+ "\u03b5\u03bd\u03bd\u03ad\u03b1;\n"
|
||||
+ "10: \u03b4\u03ad\u03ba\u03b1; "
|
||||
+ "\u03ad\u03bd\u03b4\u03b5\u03ba\u03b1; \u03b4\u03ce\u03b4\u03b5\u03ba\u03b1; "
|
||||
+ "\u03b4\u03b5\u03ba\u03b1>>;\n"
|
||||
+ "20: \u03b5\u03af\u03ba\u03bf\u03c3\u03b9; \u03b5\u03b9\u03ba\u03bf\u03c3\u03b9>>;\n"
|
||||
+ "30: \u03c4\u03c1\u03b9\u03ac\u03bd\u03c4\u03b1; \u03c4\u03c1\u03b9\u03b1\u03bd\u03c4\u03b1>>;\n"
|
||||
+ "40: \u03c3\u03b1\u03c1\u03ac\u03bd\u03c4\u03b1; \u03c3\u03b1\u03c1\u03b1\u03bd\u03c4\u03b1>>;\n"
|
||||
+ "50: \u03c0\u03b5\u03bd\u03ae\u03bd\u03c4\u03b1; \u03c0\u03b5\u03bd\u03b7\u03bd\u03c4\u03b1>>;\n"
|
||||
+ "60: \u03b5\u03be\u03ae\u03bd\u03c4\u03b1; \u03b5\u03be\u03b7\u03bd\u03c4\u03b1>>;\n"
|
||||
+ "70: \u03b5\u03b2\u03b4\u03bf\u03bc\u03ae\u03bd\u03c4\u03b1; "
|
||||
+ "\u03b5\u03b2\u03b4\u03bf\u03bc\u03b7\u03bd\u03c4\u03b1>>;\n"
|
||||
+ "80: \u03bf\u03b3\u03b4\u03cc\u03bd\u03c4\u03b1; \u03bf\u03b3\u03b4\u03bf\u03bd\u03c4\u03b1>>;\n"
|
||||
+ "90: \u03b5\u03bd\u03bd\u03b5\u03bd\u03ae\u03bd\u03c4\u03b1; "
|
||||
+ "\u03b5\u03bd\u03bd\u03b5\u03bd\u03b7\u03bd\u03c4\u03b1>>;\n"
|
||||
+ "100: \u03b5\u03ba\u03b1\u03c4\u03cc[\u03bd >>];\n"
|
||||
+ "200: \u03b4\u03b9\u03b1\u03ba\u03cc\u03c3\u03b9\u03b1[ >>];\n"
|
||||
+ "300: \u03c4\u03c1\u03b9\u03b1\u03ba\u03cc\u03c3\u03b9\u03b1[ >>];\n"
|
||||
+ "400: \u03c4\u03b5\u03c4\u03c1\u03b1\u03ba\u03cc\u03c3\u03b9\u03b1[ >>];\n"
|
||||
+ "500: \u03c0\u03b5\u03bd\u03c4\u03b1\u03ba\u03cc\u03c3\u03b9\u03b1[ >>];\n"
|
||||
+ "600: \u03b5\u03be\u03b1\u03ba\u03cc\u03c3\u03b9\u03b1[ >>];\n"
|
||||
+ "700: \u03b5\u03c0\u03c4\u03b1\u03ba\u03cc\u03c3\u03b9\u03b1[ >>];\n"
|
||||
+ "800: \u03bf\u03ba\u03c4\u03b1\u03ba\u03cc\u03c3\u03b9\u03b1[ >>];\n"
|
||||
+ "900: \u03b5\u03bd\u03bd\u03b9\u03b1\u03ba\u03cc\u03c3\u03b9\u03b1[ >>];\n"
|
||||
+ "1000: \u03c7\u03af\u03bb\u03b9\u03b1[ >>];\n"
|
||||
+ "2000: << \u03c7\u03af\u03bb\u03b9\u03b1[ >>];\n"
|
||||
+ "1,000,000: << \u03b5\u03ba\u03b1\u03c4\u03bf\u03bc\u03bc\u03b9\u03cc\u03c1\u03b9\u03bf[ >>];\n"
|
||||
+ "1,000,000,000: << \u03b4\u03b9\u03c3\u03b5\u03ba\u03b1\u03c4\u03bf\u03bc\u03bc\u03b9\u03cc\u03c1\u03b9\u03bf[ >>];\n"
|
||||
+ "1,000,000,000,000: =#,##0=" }
|
||||
// Can someone supply me with information on negatives and decimals?
|
||||
// I'm also missing the word for zero. Can someone clue me in?
|
||||
};
|
||||
}
|
@ -5,8 +5,8 @@
|
||||
*******************************************************************************
|
||||
*
|
||||
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/text/resources/Attic/NumberFormatRules_en.java,v $
|
||||
* $Date: 2000/03/10 04:07:27 $
|
||||
* $Revision: 1.2 $
|
||||
* $Date: 2001/11/07 00:30:32 $
|
||||
* $Revision: 1.3 $
|
||||
*
|
||||
*****************************************************************************************
|
||||
*/
|
||||
@ -20,7 +20,7 @@ import java.util.ListResourceBundle;
|
||||
* inherits everything from the default.
|
||||
*
|
||||
* @author Richard Gillam
|
||||
* @version $Version$ $Date: 2000/03/10 04:07:27 $
|
||||
* @version $Version$ $Date: 2001/11/07 00:30:32 $
|
||||
*/
|
||||
public class NumberFormatRules_en extends ListResourceBundle {
|
||||
/**
|
||||
@ -33,16 +33,43 @@ public class NumberFormatRules_en extends ListResourceBundle {
|
||||
return contents;
|
||||
}
|
||||
|
||||
// this is exactly the same as SpelloutRules from the root resource
|
||||
// bundle
|
||||
// This used to be the root rules, but they are English-specific, so for
|
||||
// now we just don't have any interesting rules for the root. This includes
|
||||
// the comments that used to be in the root rules.
|
||||
Object[][] contents = {
|
||||
/*
|
||||
* Spellout rules for U.S. English. This rule set has two variants:
|
||||
* %simplified is a set of rules showing the simple method of spelling
|
||||
* out numbers in English: 289 is formatted as "two hundred eighty-nine".
|
||||
* %default uses a more complicated algorithm to format
|
||||
* numbers in a more natural way: 289 is formatted as "two hundred AND
|
||||
* eighty-nine" and commas are inserted between the thousands groups for
|
||||
* values above 100,000.
|
||||
*/
|
||||
{ "SpelloutRules",
|
||||
// This rule set shows the normal simple formatting rules for English
|
||||
"%simplified:\n"
|
||||
// negative number rule. This rule is used to format negative
|
||||
// numbers. The result of formatting the number's absolute
|
||||
// value is placed where the >> is.
|
||||
+ " -x: minus >>;\n"
|
||||
// faction rule. This rule is used for formatting numbers
|
||||
// with fractional parts. The result of formatting the
|
||||
// number's integral part is substituted for the <<, and
|
||||
// the result of formatting the number's fractional part
|
||||
// (one digit at a time, e.g., 0.123 is "zero point one two
|
||||
// three") replaces the >>.
|
||||
+ " x.x: << point >>;\n"
|
||||
// the rules for the values from 0 to 19 are simply the
|
||||
// words for those numbers
|
||||
+ " zero; one; two; three; four; five; six; seven; eight; nine;\n"
|
||||
+ " ten; eleven; twelve; thirteen; fourteen; fifteen; sixteen;\n"
|
||||
+ " seventeen; eighteen; nineteen;\n"
|
||||
// beginning at 20, we use the >> to mark the position where
|
||||
// the result of formatting the number's ones digit. Thus,
|
||||
// we only need a new rule at every multiple of 10. Text in
|
||||
// backets is omitted if the value being formatted is an
|
||||
// even multiple of 10.
|
||||
+ " 20: twenty[->>];\n"
|
||||
+ " 30: thirty[->>];\n"
|
||||
+ " 40: forty[->>];\n"
|
||||
@ -51,32 +78,167 @@ public class NumberFormatRules_en extends ListResourceBundle {
|
||||
+ " 70: seventy[->>];\n"
|
||||
+ " 80: eighty[->>];\n"
|
||||
+ " 90: ninety[->>];\n"
|
||||
// beginning at 100, we can use << to mark the position where
|
||||
// the result of formatting the multiple of 100 is to be
|
||||
// inserted. Notice also that the meaning of >> has shifted:
|
||||
// here, it refers to both the ones place and the tens place.
|
||||
// The meanings of the << and >> tokens depend on the base value
|
||||
// of the rule. A rule's divisor is (usually) the highest
|
||||
// power of 10 that is less than or equal to the rule's base
|
||||
// value. The value being formatted is divided by the rule's
|
||||
// divisor, and the integral quotient is used to get the text
|
||||
// for <<, while the remainder is used to produce the text
|
||||
// for >>. Again, text in brackets is omitted if the value
|
||||
// being formatted is an even multiple of the rule's divisor
|
||||
// (in this case, an even multiple of 100)
|
||||
+ " 100: << hundred[ >>];\n"
|
||||
// The rules for the higher numbers work the same way as the
|
||||
// rule for 100: Again, the << and >> tokens depend on the
|
||||
// rule's divisor, which for all these rules is also the rule's
|
||||
// base value. To group by thousand, we simply don't have any
|
||||
// rules between 1,000 and 1,000,000.
|
||||
+ " 1000: << thousand[ >>];\n"
|
||||
+ " 1,000,000: << million[ >>];\n"
|
||||
+ " 1,000,000,000: << billion[ >>];\n"
|
||||
+ " 1,000,000,000,000: << trillion[ >>];\n"
|
||||
// overflow rule. This rule specifies that values of a
|
||||
// quadrillion or more are shown in numerals rather than words.
|
||||
// The == token means to format (with new rules) the value
|
||||
// being formatted by this rule and place the result where
|
||||
// the == is. The #,##0 inside the == signs is a
|
||||
// DecimalFormat pattern. It specifies that the value should
|
||||
// be formatted with a DecimalFormat object, and that it
|
||||
// should be formatted with no decimal places, at least one
|
||||
// digit, and a thousands separator.
|
||||
+ " 1,000,000,000,000,000: =#,##0=;\n"
|
||||
|
||||
// %default is a more elaborate form of %simplified; It is basically
|
||||
// the same, except that it introduces "and" before the ones digit
|
||||
// when appropriate (basically, between the tens and ones digits) and
|
||||
// separates the thousands groups with commas in values over 100,000.
|
||||
+ "%default:\n"
|
||||
// negative-number and fraction rules. These are the same
|
||||
// as those for %simplified, but ave to be stated here too
|
||||
// because this is an entry point
|
||||
+ " -x: minus >>;\n"
|
||||
+ " x.x: << point >>;\n"
|
||||
// just use %simplified for values below 100
|
||||
+ " =%simplified=;\n"
|
||||
// for values from 100 to 9,999 use %%and to decide whether or
|
||||
// not to interpose the "and"
|
||||
+ " 100: << hundred[ >%%and>];\n"
|
||||
+ " 1000: << thousand[ >%%and>];\n"
|
||||
// for values of 100,000 and up, use %%commas to interpose the
|
||||
// commas in the right places (and also to interpose the "and")
|
||||
+ " 100,000>>: << thousand[>%%commas>];\n"
|
||||
+ " 1,000,000: << million[>%%commas>];\n"
|
||||
+ " 1,000,000,000: << billion[>%%commas>];\n"
|
||||
+ " 1,000,000,000,000: << trillion[>%%commas>];\n"
|
||||
+ " 1,000,000,000,000,000: =#,##0=;\n"
|
||||
// if the value passed to this rule set is greater than 100, don't
|
||||
// add the "and"; if it's less than 100, add "and" before the last
|
||||
// digits
|
||||
+ "%%and:\n"
|
||||
+ " and =%default=;\n"
|
||||
+ " 100: =%default=;\n"
|
||||
// this rule set is used to place the commas
|
||||
+ "%%commas:\n"
|
||||
// for values below 100, add "and" (the apostrophe at the
|
||||
// beginning is ignored, but causes the space that follows it
|
||||
// to be significant: this is necessary because the rules
|
||||
// calling %%commas don't put a space before it)
|
||||
+ " ' and =%default=;\n"
|
||||
// put a comma after the thousands (or whatever preceded the
|
||||
// hundreds)
|
||||
+ " 100: , =%default=;\n"
|
||||
// put a comma after the millions (or whatever precedes the
|
||||
// thousands)
|
||||
+ " 1000: , <%default< thousand, >%default>;\n"
|
||||
// and so on...
|
||||
+ " 1,000,000: , =%default=;"
|
||||
// %%lenient-parse isn't really a set of number formatting rules;
|
||||
// it's a set of collation rules. Lenient-parse mode uses a Collator
|
||||
// object to compare fragments of the text being parsed to the text
|
||||
// in the rules, allowing more leeway in the matching text. This set
|
||||
// of rules tells the formatter to ignore commas when parsing (it
|
||||
// already ignores spaces, which is why we refer to the space; it also
|
||||
// ignores hyphens, making "twenty one" and "twenty-one" parse
|
||||
// identically)
|
||||
+ "%%lenient-parse:\n"
|
||||
+ " & ' ' , ',' ;\n" }
|
||||
+ " & ' ' , ',' ;\n" },
|
||||
|
||||
/*
|
||||
* This rule set adds an English ordinal abbreviation to the end of a
|
||||
* number. For example, 2 is formatted as "2nd". Parsing doesn't work with
|
||||
* this rule set. To parse, use DecimalFormat on the numeral.
|
||||
*/
|
||||
{ "OrdinalRules",
|
||||
// this rule set formats the numeral and calls %%abbrev to
|
||||
// supply the abbreviation
|
||||
"%main:\n"
|
||||
+ " =#,##0==%%abbrev=;\n"
|
||||
// this rule set supplies the abbreviation
|
||||
+ "%%abbrev:\n"
|
||||
// the abbreviations. Everything from 4 to 19 ends in "th"
|
||||
+ " th; st; nd; rd; th;\n"
|
||||
// at 20, we begin repeating the cycle every 10 (13 is "13th",
|
||||
// but 23 and 33 are "23rd" and "33rd") We do this by
|
||||
// ignoring all bug the ones digit in selecting the abbreviation
|
||||
+ " 20: >>;\n"
|
||||
// at 100, we repeat the whole cycle by considering only the
|
||||
// tens and ones digits in picking an abbreviation
|
||||
+ " 100: >>;\n" },
|
||||
|
||||
/*
|
||||
* This rule set formats a number of seconds in sexagesimal notation
|
||||
* (i.e., hours, minutes, and seconds). %with-words formats it with
|
||||
* words (3,740 is "1 hour, 2 minutes, 20 seconds") and %in-numerals
|
||||
* formats it entirely in numerals (3,740 is "1:02:20").
|
||||
*/
|
||||
{ "DurationRules",
|
||||
// main rule set for formatting with words
|
||||
"%with-words:\n"
|
||||
// take care of singular and plural forms of "second"
|
||||
+ " 0 seconds; 1 second; =0= seconds;\n"
|
||||
// use %%min to format values greater than 60 seconds
|
||||
+ " 60/60: <%%min<[, >>];\n"
|
||||
// use %%hr to format values greater than 3,600 seconds
|
||||
// (the ">>>" below causes us to see the number of minutes
|
||||
// when when there are zero minutes)
|
||||
+ " 3600/60: <%%hr<[, >>>];\n"
|
||||
// this rule set takes care of the singular and plural forms
|
||||
// of "minute"
|
||||
+ "%%min:\n"
|
||||
+ " 0 minutes; 1 minute; =0= minutes;\n"
|
||||
// this rule set takes care of the singular and plural forms
|
||||
// of "hour"
|
||||
+ "%%hr:\n"
|
||||
+ " 0 hours; 1 hour; =0= hours;\n"
|
||||
|
||||
// main rule set for formatting in numerals
|
||||
+ "%in-numerals:\n"
|
||||
// values below 60 seconds are shown with "sec."
|
||||
+ " =0= sec.;\n"
|
||||
// higher values are shown with colons: %%min-sec is used for
|
||||
// values below 3,600 seconds...
|
||||
+ " 60: =%%min-sec=;\n"
|
||||
// ...and %%hr-min-sec is used for values of 3,600 seconds
|
||||
// and above
|
||||
+ " 3600: =%%hr-min-sec=;\n"
|
||||
// this rule causes values of less than 10 minutes to show without
|
||||
// a leading zero
|
||||
+ "%%min-sec:\n"
|
||||
+ " 0: :=00=;\n"
|
||||
+ " 60/60: <0<>>;\n"
|
||||
// this rule set is used for values of 3,600 or more. Minutes are always
|
||||
// shown, and always shown with two digits
|
||||
+ "%%hr-min-sec:\n"
|
||||
+ " 0: :=00=;\n"
|
||||
+ " 60/60: <00<>>;\n"
|
||||
+ " 3600/60: <#,##0<:>>>;\n"
|
||||
// the lenient-parse rules allow several different characters to be used
|
||||
// as delimiters between hours, minutes, and seconds
|
||||
+ "%%lenient-parse:\n"
|
||||
+ " & ':' = '.' = ' ' = '-';\n" }
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user