]>
Commit | Line | Data |
---|---|---|
374ca955 A |
1 | // *************************************************************************** |
2 | // * | |
3 | // * Copyright (C) 2004, International Business Machines | |
4 | // * Corporation and others. All Rights Reserved. | |
5 | // * | |
6 | // *************************************************************************** | |
7 | // | |
8 | ||
9 | mt { | |
10 | // Spellout rules. Experimental. | |
11 | ||
12 | SpelloutRules { | |
13 | // This rule set shows the normal simple formatting rules for English | |
14 | "%simplified:\n" | |
15 | // negative number rule. This rule is used to format negative | |
16 | // numbers. The result of formatting the number's absolute | |
17 | // value is placed where the >> is. | |
18 | "-x: minus >>;\n" | |
19 | // faction rule. This rule is used for formatting numbers | |
20 | // with fractional parts. The result of formatting the | |
21 | // number's integral part is substituted for the <<, and | |
22 | // the result of formatting the number's fractional part | |
23 | // (one digit at a time, e.g., 0.123 is "zero punt one two | |
24 | // three") replaces the >>. | |
25 | "x.x: << punt >>;\n" | |
26 | // the rules for the values from 0 to 19 are simply the | |
27 | // words for those numbers | |
28 | "żero; wieħed; tnejn; tlieta; erbgħa; ħamsa; sitta; sebgħa; tmienja; disgħa;\n" | |
29 | "għaxra; ħdax; tnax; tlettax; erbatax; ħmistax; sittax;\n" | |
30 | " sbatax; tmintax; dsatax;\n" | |
31 | // beginning at 20, we use the >> to mark the position where | |
32 | // the result of formatting the number's ones digit. Thus, | |
33 | // we only need a new rule at every multiple of 10. Text in | |
34 | // backets is omitted if the value being formatted is an | |
35 | // even multiple of 10. | |
36 | "20: [>> u ]għoxrin;\n" | |
37 | "30: [>> u ]tletin;\n" | |
38 | "40: [>> u ]erbgħin;\n" | |
39 | "50: [>> u ]ħamsin;\n" | |
40 | "60: [>> u ]sittin;\n" | |
41 | "70: [>> u ]sebgħin;\n" | |
42 | "80: [>> u ]tmenin;\n" | |
43 | "90: [>> u ]disgħin;\n" | |
44 | // beginning at 100, we can use << to mark the position where | |
45 | // the result of formatting the multiple of 100 is to be | |
46 | // inserted. Notice also that the meaning of >> has shifted: | |
47 | // here, it refers to both the ones place and the tens place. | |
48 | // The meanings of the << and >> tokens depend on the base value | |
49 | // of the rule. A rule's divisor is (usually) the highest | |
50 | // power of 10 that is less than or equal to the rule's base | |
51 | // value. The value being formatted is divided by the rule's | |
52 | // divisor, and the integral quotient is used to get the text | |
53 | // for <<, while the remainder is used to produce the text | |
54 | // for >>. Again, text in brackets is omitted if the value | |
55 | // being formatted is an even multiple of the rule's divisor | |
56 | // (in this case, an even multiple of 100) | |
57 | "100: mija[ u >>];\n" | |
58 | "200: mitejn[ u >>];\n" | |
59 | // The rules for the higher numbers work the same way as the | |
60 | // rule for 100: Again, the << and >> tokens depend on the | |
61 | // rule's divisor, which for all these rules is also the rule's | |
62 | // base value. To group by thousand, we simply don't have any | |
63 | // rules between 1,000 and 1,000,000. | |
64 | "1000: << elf[ u >>];\n" | |
65 | "2000: << elfejn[ u >>];\n" | |
66 | "3000: tliet elef [ u >>];\n" | |
67 | "1,000,000: << miljun[ u >>];\n" | |
68 | "1,000,000,000: << biljun[ >>];\n" | |
69 | "1,000,000,000,000: << triljun[ >>];\n" | |
70 | // overflow rule. This rule specifies that values of a | |
71 | // quadrillion or more are shown in numerals rather than words. | |
72 | // The == token means to format (with new rules) the value | |
73 | // being formatted by this rule and place the result where | |
74 | // the == is. The #,##0 inside the == signs is a | |
75 | // DecimalFormat pattern. It specifies that the value should | |
76 | // be formatted with a DecimalFormat object, and that it | |
77 | // should be formatted with no decimal places, at least one | |
78 | // digit, and a thousands separator. | |
79 | "1,000,000,000,000,000: =#,##0=;\n" | |
80 | ||
81 | // %default is a more elaborate form of %simplified; It is basically | |
82 | // the same, except that it introduces "and" before the ones digit | |
83 | // when appropriate (basically, between the tens and ones digits) and | |
84 | // separates the thousands groups with commas in values over 100,000. | |
85 | "%default:\n" | |
86 | // negative-number and fraction rules. These are the same | |
87 | // as those for %simplified, but have to be stated here too | |
88 | // because this is an entry point | |
89 | "-x: minus >>;\n" | |
90 | "x.x: << punt >>;\n" | |
91 | // just use %simplified for values below 100 | |
92 | "=%simplified=;\n" | |
93 | // for values from 100 to 9,999 use %%and to decide whether or | |
94 | // not to interpose the "and" | |
95 | "100: mija[ >%%and>];\n" | |
96 | "200: mitejn[ >%%and>];\n" | |
97 | "300: tlett mija[ >%%and>];\n" | |
98 | "400: erbgħa mija[ >%%and>];\n" | |
99 | "500: ħames mija[ >%%and>];\n" | |
100 | "600: sitt mija[ >%%and>];\n" | |
101 | "700: sebgħa mija[ >%%and>];\n" | |
102 | "800: tmin mija[ >%%and>];\n" | |
103 | "900: disgħa mija[ >%%and>];\n" | |
104 | "1000: << elf[ >%%and>];\n" | |
105 | // for values of 100,000 and up, use %%commas to interpose the | |
106 | // commas in the right places (and also to interpose the "and") | |
107 | "100,000>>: << thousand[>%%commas>];\n" | |
108 | "1,000,000: << million[>%%commas>];\n" | |
109 | "1,000,000,000: << billion[>%%commas>];\n" | |
110 | "1,000,000,000,000: << trillion[>%%commas>];\n" | |
111 | "1,000,000,000,000,000: =#,##0=;\n" | |
112 | // if the value passed to this rule set is greater than 100, don't | |
113 | // add the "and"; if it's less than 100, add "and" before the last | |
114 | // digits | |
115 | "%%and:\n" | |
116 | "u =%default=;\n" | |
117 | "100: =%default=;\n" | |
118 | // this rule set is used to place the commas | |
119 | "%%commas:\n" | |
120 | // for values below 100, add "and" (the apostrophe at the | |
121 | // beginning is ignored, but causes the space that follows it | |
122 | // to be significant: this is necessary because the rules | |
123 | // calling %%commas don't put a space before it) | |
124 | "' and =%default=;\n" | |
125 | // put a comma after the thousands (or whatever preceded the | |
126 | // hundreds) | |
127 | "100: , =%default=;\n" | |
128 | // put a comma after the millions (or whatever precedes the | |
129 | // thousands) | |
130 | "1000: , <%default< thousand, >%default>;\n" | |
131 | // and so on... | |
132 | "1,000,000: , =%default=;" | |
133 | // %%lenient-parse isn't really a set of number formatting rules; | |
134 | // it's a set of collation rules. Lenient-parse mode uses a Collator | |
135 | // object to compare fragments of the text being parsed to the text | |
136 | // in the rules, allowing more leeway in the matching text. This set | |
137 | // of rules tells the formatter to ignore commas when parsing (it | |
138 | // already ignores spaces, which is why we refer to the space; it also | |
139 | // ignores hyphens, making "twenty one" and "twenty-one" parse | |
140 | // identically) | |
141 | "%%lenient-parse:\n" | |
142 | // "& ' ' , ',' ;\n" | |
143 | "&\u0000 << ' ' << ',' << '-'; \n" | |
144 | } | |
145 | ||
146 | ||
147 | DurationRules { | |
148 | // main rule set for formatting with words | |
149 | "%with-words:\n" | |
150 | // take care of singular and plural forms of "second" | |
151 | "0 sekondi; 1 sekonda; =0= sekondi;\n" | |
152 | // use %%min to format values greater than 60 seconds | |
153 | "60/60: <%%min<[, >>];\n" | |
154 | // use %%hr to format values greater than 3,600 seconds | |
155 | // (the ">>>" below causes us to see the number of minutes | |
156 | // when when there are zero minutes) | |
157 | "3600/60: <%%hr<[, >>>];\n" | |
158 | // this rule set takes care of the singular and plural forms | |
159 | // of "minute" | |
160 | "%%min:\n" | |
161 | "0 minuti; 1 minuta; =0= minuti;\n" | |
162 | // this rule set takes care of the singular and plural forms | |
163 | // of "hour" | |
164 | "%%hr:\n" | |
165 | "0 siegħat; 1 siegħa; =0= siegħat;\n" | |
166 | ||
167 | // main rule set for formatting in numerals | |
168 | "%in-numerals:\n" | |
169 | // values below 60 seconds are shown with "sec." | |
170 | "=0= sek.;\n" | |
171 | // higher values are shown with colons: %%min-sec is used for | |
172 | // values below 3,600 seconds... | |
173 | "60: =%%min-sec=;\n" | |
174 | // ...and %%hr-min-sec is used for values of 3,600 seconds | |
175 | // and above | |
176 | "3600: =%%hr-min-sec=;\n" | |
177 | // this rule causes values of less than 10 minutes to show without | |
178 | // a leading zero | |
179 | "%%min-sec:\n" | |
180 | "0: :=00=;\n" | |
181 | "60/60: <0<>>;\n" | |
182 | // this rule set is used for values of 3,600 or more. Minutes are always | |
183 | // shown, and always shown with two digits | |
184 | "%%hr-min-sec:\n" | |
185 | "0: :=00=;\n" | |
186 | "60/60: <00<>>;\n" | |
187 | "3600/60: <#,##0<:>>>;\n" | |
188 | // the lenient-parse rules allow several different characters to be used | |
189 | // as delimiters between hours, minutes, and seconds | |
190 | "%%lenient-parse:\n" | |
191 | "& ':' = '.' = ' ' = '-';\n" | |
192 | } | |
193 | } |