Rev 16172 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
10915 | bpr | 1 | !if $wims_read_parm!=slib_header |
13585 | bpr | 2 | !goto proc |
10915 | bpr | 3 | !endif |
4 | |||
15639 | bpr | 5 | slib_author=Bernadette, Perrin-Riou; Raoul, Hatterer; Eric, Reyssat |
6 | slib_parms=3\ |
||
15626 | reyssat | 7 | ,number\ |
8 | ,language (fr,en,it ; default=fr)\ |
||
16169 | bpr | 9 | ,space separated options in brackets (works in french): frrule (trad/1990, default=1990),type (card/ord, default=card), plural (yes/no, default=no), fracdenom (yes/no, default=yes), 70=septante 80=huitante 90=nonante |
15626 | reyssat | 10 | |
16165 | bpr | 11 | slib_example=5678\ |
10915 | bpr | 12 | [678,122]\ |
13 | [295,180],fr\ |
||
11751 | bpr | 14 | [295,180],en\ |
16188 | bpr | 15 | [181,1008,1081,200,201,280,1857]\ |
16 | [181,1008,1081,200,201,280,1857],en\ |
||
17 | [181,1008,1081,200,201,280,1857],it\ |
||
15626 | reyssat | 18 | 80080,fr\ |
11751 | bpr | 19 | [9880,99120],fr\ |
14528 | czzmrn | 20 | [9880,99120],en\ |
15626 | reyssat | 21 | [9880,99120],it\ |
15639 | bpr | 22 | 371,fr,[type=ord plural=yes]\ |
23 | 371,fr,[type=ord plural=yes frrule=trad]\ |
||
24 | 4,fr,[type=ord]\ |
||
25 | 4,fr,[type=ord plural=yes fracdenom=no]\ |
||
15626 | reyssat | 26 | [0,1,10,100,1000,10000,100000,1000000,10000000,1000000000], fr\ |
14528 | czzmrn | 27 | [0,1,10,100,1000,10000,100000,1000000,10000000], en\ |
16161 | bpr | 28 | [0,1,10,100,1000,10000,100000,1000000,10000000,1000000000], it\ |
16169 | bpr | 29 | [678,9880,99120],fr,[type=ord 70=septante 80=huitante 90=nonante]\ |
30 | [485,95,1881,91],fr,[70=septante 80=huiptante] |
||
11751 | bpr | 31 | |
10915 | bpr | 32 | !exit |
33 | |||
34 | :proc |
||
35 | |||
15626 | reyssat | 36 | |
37 | !! Extraction des paramètres et options |
||
38 | !distribute item $wims_read_parm into slib_data,slib_language,slib_options |
||
15639 | bpr | 39 | slib_options=!declosing $slib_options |
15626 | reyssat | 40 | |
41 | slib_rule=!getopt frrule in $slib_options |
||
42 | !default slib_rule=1990 |
||
43 | slib_type=!getopt type in $slib_options |
||
44 | !default slib_type=card |
||
45 | slib_plural=!getopt plural in $slib_options |
||
46 | !default slib_plural=no |
||
47 | slib_fden=!getopt fracdenom in $slib_options |
||
48 | !default slib_fden=yes |
||
16169 | bpr | 49 | slib_variant7=!getopt 70 in $slib_options |
50 | slib_variant8=!getopt 80 in $slib_options |
||
51 | slib_variant9=!getopt 90 in $slib_options |
||
11751 | bpr | 52 | slib_language= $(wims_read_parm[2]) |
15766 | czzmrn | 53 | !if $slib_language notwordof it fr en |
54 | slib_language=fr |
||
55 | !endif |
||
10915 | bpr | 56 | !reset slib_out |
57 | slib_data= $(wims_read_parm[1]) |
||
58 | slib_data=!declosing $slib_data |
||
11751 | bpr | 59 | !if $slib_language=en |
60 | !! english transcription |
||
61 | !! author : Raoul HATTERER |
||
62 | !! algorithm: http://www.blackwasp.co.uk/NumberToWords.aspx |
||
10915 | bpr | 63 | |
11751 | bpr | 64 | slib_smallNumbers = one, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve, thirteen, fourteen, fifteen, sixteen, seventeen, eighteen, nineteen |
65 | slib_tyWords = , twenty, thirty, forty, fifty, sixty, seventy, eighty, ninety |
||
66 | slib_scaleNumbers = ,thousand, million, billion |
||
67 | |||
68 | !for slib_number in $slib_data |
||
69 | !! Zero Rule. |
||
70 | !! If the value is zero then the number in words is 'zero' |
||
71 | !! and no other rules apply. |
||
72 | !if $slib_number==0 |
||
73 | slib_combined=zero |
||
74 | !else |
||
75 | !! Three Digit Rule. |
||
76 | !! The integer value is split into groups of three digits starting from the right-hand side. |
||
77 | !! Once converted to text, the three-digit groups are recombined with the addition |
||
15638 | reyssat | 78 | !! of the relevant scale number (thousand, million, billion). |
11751 | bpr | 79 | |
80 | !! The integer value is split into groups of three digits starting from the right-hand side. |
||
15639 | bpr | 81 | !reset slib_3digitsGroups |
82 | !for slib_scale= 1 to 4 |
||
83 | slib_3digits=!char -3 to -1 of $slib_number |
||
84 | slib_3digitsGroups=!append item $slib_3digits to $slib_3digitsGroups |
||
11751 | bpr | 85 | slib_number=!char 1 to -4 of $slib_number |
15639 | bpr | 86 | !next |
11751 | bpr | 87 | |
88 | !! Each set of three digits is then processed individually as a number of hundreds, tens and units. |
||
15639 | bpr | 89 | !reset slib_textGroups |
90 | !for slib_scale= 1 to 4 |
||
91 | slib_3digits= !column $slib_scale of $slib_3digitsGroups |
||
92 | !if $slib_3digits > 99 |
||
93 | slib_hundreds=!char -3 of $slib_3digits |
||
94 | !else |
||
95 | slib_hundreds=0 |
||
96 | !endif |
||
97 | slib_tensUnits=!char -2 to -1 of $slib_3digits |
||
98 | slib_tens=!char -2 of $slib_3digits |
||
99 | slib_units=!char -1 of $slib_3digits |
||
100 | !! Hundreds Rules. |
||
101 | !! If the hundreds portion of a three-digit group is not zero, |
||
102 | !! the number of hundreds is added as a word. |
||
103 | !! If the three-digit group is exactly divisible by one hundred, |
||
104 | !! the text 'hundred' is appended. |
||
105 | !! If not, the text "hundred and" is appended. |
||
106 | !! eg. 'two hundred' or 'one hundred and twelve' |
||
107 | !reset slib_3digitsText |
||
108 | !if $slib_hundreds!=0 |
||
109 | slib_3digitsText = !column $slib_hundreds of $slib_smallNumbers |
||
11751 | bpr | 110 | slib_3digitsText = $slib_3digitsText hundred |
15639 | bpr | 111 | !if $slib_tensUnits!=00 |
112 | slib_3digitsText = $slib_3digitsText and |
||
113 | !endif |
||
114 | !endif |
||
11751 | bpr | 115 | |
15639 | bpr | 116 | !! Tens Rules. |
117 | !! If the tens section of a three-digit group is two or higher, |
||
118 | !! the appropriate '-ty' word (twenty, thirty, etc.) is added |
||
119 | !! to the text and followed by the name of the third digit |
||
120 | !! (unless the third digit is a zero, which is ignored). |
||
121 | !! If the tens and the units are both zero, no text is added. |
||
122 | !! For any other value, the name of the one or two-digit number |
||
123 | !! is added as a special case. |
||
124 | !if $slib_tens >= 2 |
||
125 | slib_tyWord=!column $slib_tens of $slib_tyWords |
||
126 | slib_3digitsText= $slib_3digitsText $slib_tyWord |
||
127 | !if $slib_units!= 0 |
||
128 | slib_unitWord=!column $slib_units of $slib_smallNumbers |
||
129 | slib_3digitsText=$slib_3digitsText-$slib_unitWord |
||
130 | !endif |
||
131 | !else |
||
132 | !if $[$slib_tensUnits]!= 0 |
||
133 | slib_tenUnitWord=!column $slib_tensUnits of $slib_smallNumbers |
||
134 | slib_3digitsText= $slib_3digitsText $slib_tenUnitWord |
||
135 | !endif |
||
136 | !endif |
||
137 | !if $slib_3digits==000 |
||
138 | slib_3digitsText=zero |
||
139 | !endif |
||
140 | slib_textGroups=!append item $slib_3digitsText to $slib_textGroups |
||
141 | !next |
||
11751 | bpr | 142 | |
15639 | bpr | 143 | !! Recombination Rules. |
144 | !! When recombining the translated three-digit groups, |
||
145 | !! each group except the last is followed by a large number name |
||
146 | !! and a comma, |
||
147 | !! unless the group is blank and therefore not included at all. |
||
148 | !! One exception is when the final group does not include |
||
149 | !! any hundreds and there is more than one non-blank group. |
||
150 | !! In this case, the final comma is replaced with 'and'. |
||
151 | !! eg. 'one billion, one million and twelve'. |
||
11751 | bpr | 152 | |
15639 | bpr | 153 | slib_combined = !column 1 of $slib_textGroups |
154 | !if $slib_combined=zero |
||
155 | slib_combined= |
||
156 | !endif |
||
157 | slib_3digits=!column 1 of $slib_3digitsGroups |
||
158 | !if $[$slib_3digits]>0 and $[$slib_3digits]<100 |
||
159 | slib_appendAnd=true |
||
160 | !else |
||
161 | slib_appendAnd=false |
||
162 | !endif |
||
163 | !for slib_scale = 2 to 4 |
||
164 | slib_3digits=!column $slib_scale of $slib_3digitsGroups |
||
165 | !if $[$slib_3digits]!=0 |
||
166 | slib_3digitsText=!column $slib_scale of $slib_textGroups |
||
167 | slib_scaleNumber=!column $slib_scale of $slib_scaleNumbers |
||
168 | slib_prefix = $slib_3digitsText $slib_scaleNumber |
||
169 | !if $slib_appendAnd==true |
||
170 | slib_prefix=$slib_prefix and |
||
171 | slib_appendAnd=false |
||
172 | !else |
||
173 | slib_empty=!charcnt $slib_combined |
||
174 | !if $slib_empty!=0 |
||
175 | slib_prefix=$slib_prefix, |
||
176 | !endif |
||
177 | !endif |
||
178 | slib_combined=$slib_prefix $slib_combined |
||
179 | !endif |
||
180 | !next |
||
11751 | bpr | 181 | !endif |
16188 | bpr | 182 | slib_combined=!items2words $slib_combined |
183 | slib_combined=!singlespace $slib_combined |
||
11751 | bpr | 184 | slib_out=!append item $slib_combined to $slib_out |
185 | !next |
||
14528 | czzmrn | 186 | !goto end |
15639 | bpr | 187 | !! todo: ten million should be ten millions etc. |
188 | !endif |
||
14528 | czzmrn | 189 | |
190 | !if $slib_language=it |
||
15639 | bpr | 191 | !! use adapted English algorithm (MC) |
14528 | czzmrn | 192 | slib_smallNumbers = uno, due, tre, quattro, cinque, sei, sette, otto, nove, dieci, undici, dodici, tredici, quattordici, quindici, sedici, diciassette, diciotto, diciannove |
193 | slib_tyWords = , venti, trenta, quaranta, cinquanta, sessanta, settanta, ottanta, novanta |
||
194 | slib_scaleNumbers = ,mila, milioni, miliardi |
||
195 | |||
196 | !for slib_number in $slib_data |
||
197 | !! Zero Rule. |
||
198 | !! If the value is zero then the number in words is 'zero' |
||
199 | !! and no other rules apply. |
||
200 | !if $slib_number==0 |
||
201 | slib_combined=zero |
||
202 | !else |
||
203 | !! Three Digit Rule. |
||
204 | !! The integer value is split into groups of three digits starting from the right-hand side. |
||
205 | !! Once converted to text, the three-digit groups are recombined with the addition |
||
15639 | bpr | 206 | !! of the relevant scale number (thousand, million, billion). |
14528 | czzmrn | 207 | |
208 | !! The integer value is split into groups of three digits starting from the right-hand side. |
||
15639 | bpr | 209 | !reset slib_3digitsGroups |
210 | !for slib_scale= 1 to 4 |
||
211 | slib_3digits=!char -3 to -1 of $slib_number |
||
212 | slib_3digitsGroups=!append item $slib_3digits to $slib_3digitsGroups |
||
14528 | czzmrn | 213 | slib_number=!char 1 to -4 of $slib_number |
15639 | bpr | 214 | !next |
14528 | czzmrn | 215 | |
216 | !! Each set of three digits is then processed individually as a number of hundreds, tens and units. |
||
15639 | bpr | 217 | !reset slib_textGroups |
218 | !for slib_scale= 1 to 4 |
||
219 | slib_3digits= !column $slib_scale of $slib_3digitsGroups |
||
220 | !if $slib_3digits > 99 |
||
221 | slib_hundreds=!char -3 of $slib_3digits |
||
222 | !else |
||
223 | slib_hundreds=0 |
||
224 | !endif |
||
225 | slib_tensUnits=!char -2 to -1 of $slib_3digits |
||
226 | slib_tens=!char -2 of $slib_3digits |
||
227 | slib_units=!char -1 of $slib_3digits |
||
228 | !! Hundreds Rules. |
||
229 | !! If the hundreds portion of a three-digit group is not zero |
||
230 | !! if it is 1, the word "uno" is omitted, |
||
231 | !! the number of hundreds is added as a word. |
||
232 | !reset slib_3digitsText |
||
233 | !if $slib_hundreds!=0 |
||
234 | slib_3digitsText = !column $slib_hundreds of $slib_smallNumbers |
||
235 | !if $slib_hundreds==1 |
||
236 | slib_3digitsText = cento |
||
237 | !else |
||
238 | slib_3digitsText = $slib_3digitsText cento |
||
239 | !endif |
||
240 | !endif |
||
14528 | czzmrn | 241 | |
15639 | bpr | 242 | !! Tens Rules. |
243 | !! If the tens section of a three-digit group is two or higher, |
||
244 | !! the appropriate '-ty' word (twenty, thirty, etc.) is added |
||
245 | !! to the text and followed by the name of the third digit |
||
246 | !! (unless the third digit is a zero, which is ignored). |
||
247 | !! If the tens and the units are both zero, no text is added. |
||
248 | !! For any other value, the name of the one or two-digit number |
||
249 | !! is added as a special case. |
||
250 | !if $slib_tens >= 2 |
||
251 | slib_tyWord=!column $slib_tens of $slib_tyWords |
||
252 | slib_3digitsText= $slib_3digitsText $slib_tyWord |
||
253 | !if $slib_units!= 0 |
||
254 | slib_unitWord=!column $slib_units of $slib_smallNumbers |
||
255 | slib_3digitsText=$slib_3digitsText $slib_unitWord |
||
256 | !endif |
||
257 | !else |
||
258 | !if $[$slib_tensUnits]!= 0 |
||
259 | slib_tenUnitWord=!column $slib_tensUnits of $slib_smallNumbers |
||
260 | slib_3digitsText= $slib_3digitsText $slib_tenUnitWord |
||
261 | !endif |
||
262 | !endif |
||
263 | !if $slib_3digits==000 |
||
264 | slib_3digitsText=zero |
||
265 | !endif |
||
266 | slib_3digitsText=!nospace $slib_3digitsText |
||
267 | slib_textGroups=!append item $slib_3digitsText to $slib_textGroups |
||
268 | !next |
||
14528 | czzmrn | 269 | |
15639 | bpr | 270 | !! Recombination Rules. |
271 | !! When recombining the translated three-digit groups, |
||
272 | !! each group except the last is followed by a large number name |
||
273 | !! unless the group is blank and therefore not included at all. |
||
274 | !! One exception is when the final group does not include |
||
275 | !! any hundreds and there is more than one non-blank group. |
||
276 | !! In this case, the final comma is replaced with 'and'. |
||
277 | !! eg. 'one billion, one million and twelve'. |
||
14528 | czzmrn | 278 | |
15639 | bpr | 279 | slib_combined = !column 1 of $slib_textGroups |
280 | !if $slib_combined=zero |
||
281 | slib_combined= |
||
282 | !endif |
||
283 | slib_3digits=!column 1 of $slib_3digitsGroups |
||
284 | !if $[$slib_3digits]>0 and $[$slib_3digits]<100 |
||
285 | slib_appendAnd=true |
||
286 | !else |
||
287 | slib_appendAnd=false |
||
288 | !endif |
||
289 | !for slib_scale = 2 to 4 |
||
290 | slib_3digits=!column $slib_scale of $slib_3digitsGroups |
||
291 | !if $[$slib_3digits]!=0 |
||
292 | slib_3digitsText=!column $slib_scale of $slib_textGroups |
||
293 | slib_scaleNumber=!column $slib_scale of $slib_scaleNumbers |
||
294 | !if $[$slib_3digits]==1 |
||
295 | !if $slib_scale=2 |
||
296 | slib_prefix = mille |
||
297 | !else |
||
298 | !! !if $slib_prefix==2 |
||
299 | slib_prefix = un $slib_scaleNumber |
||
300 | !! !else |
||
301 | !! slib_prefix = $slib_scaleNumber |
||
302 | !! !endif |
||
303 | !endif |
||
304 | !else |
||
305 | !if $slib_scale=2 |
||
306 | slib_prefix = $slib_3digitsText$slib_scaleNumber |
||
307 | !else |
||
308 | slib_prefix = $slib_3digitsText $slib_scaleNumber |
||
309 | !endif |
||
310 | !endif |
||
311 | !if $slib_appendAnd==true |
||
312 | slib_prefix=$slib_prefix e |
||
313 | slib_appendAnd=false |
||
314 | !else |
||
315 | slib_empty=!charcnt $slib_combined |
||
316 | !if $slib_empty!=0 |
||
317 | slib_prefix=$slib_prefix |
||
318 | !endif |
||
319 | !endif |
||
320 | slib_combined=$slib_prefix $slib_combined |
||
321 | !endif |
||
322 | !next |
||
14528 | czzmrn | 323 | !endif |
324 | slib_out=!append item $slib_combined to $slib_out |
||
325 | !next |
||
15639 | bpr | 326 | !! contrazioni eufoniche di vocali |
14528 | czzmrn | 327 | slib_out=!replace internal oo by o in $slib_out |
328 | slib_out=!replace internal antauno by antuno in $slib_out |
||
14529 | czzmrn | 329 | slib_out=!replace internal antaotto by antotto in $slib_out |
14528 | czzmrn | 330 | slib_out=!replace internal tiuno by tuno in $slib_out |
14529 | czzmrn | 331 | slib_out=!replace internal tiotto by totto in $slib_out |
15639 | bpr | 332 | !! need singular |
14528 | czzmrn | 333 | slib_out=!replace internal un milioni by un milione in $slib_out |
334 | slib_out=!replace internal un miliardi by un miliardo in $slib_out |
||
15639 | bpr | 335 | !goto end |
14528 | czzmrn | 336 | !endif |
337 | |||
15626 | reyssat | 338 | !if $slib_language=fr |
15638 | reyssat | 339 | !! use adapted English algorithm (E.R.) |
340 | !! treats simultaneously cardinal and ordinal numbers |
||
15639 | bpr | 341 | |
15626 | reyssat | 342 | slib_smallNumbers = un, deux, trois, quatre, cinq, six, sept, huit, neuf, dix, onze, douze, treize, quatorze, quinze, seize, dix-sept, dix-huit, dix-neuf |
15638 | reyssat | 343 | slib_tyWords = , vingt, trente, quarante, cinquante, soixante, soixante, quatre-vingt, quatre-vingt |
15626 | reyssat | 344 | slib_scaleNumbers = ,mille, million, milliard |
345 | slib_smallNumbersOrd = unième, deuxième, troisième, quatrième, cinquième, sixième, septième, huitième, neuvième, dixième, onzième, douzième, treizième, quatorzième, quinzième, seizième, dix-septième, dix-huitième, dix-neuvième |
||
15639 | bpr | 346 | slib_tyWordsOrd = , vingtième, trentième, quarantième, cinquantième, soixantième, , quatre-vingtième, |
15626 | reyssat | 347 | slib_scaleNumbersOrd = ,millième, millionième, milliardième |
16165 | bpr | 348 | slib_var1=7,9 |
349 | slib_var2=2,3,4,5,6,8 |
||
350 | slib_var3=8 |
||
16169 | bpr | 351 | !if $slib_variant7!=$empty |
352 | slib_tyWords=!replace item number 7 by $slib_variant7 in $slib_tyWords |
||
353 | slib_variantie7=!char 1 to -2 of $slib_variant7 |
||
354 | slib_variantie7=$(slib_variantie7)ième |
||
355 | slib_tyWordsOrd=!replace item number 7 by $slib_variantie7 in $slib_tyWordsOrd |
||
16165 | bpr | 356 | slib_var1=!listcomplement 7 in $slib_var1 |
357 | slib_var2=$slib_var2,7 |
||
358 | !endif |
||
16169 | bpr | 359 | !if $slib_variant8!=$empty |
360 | slib_tyWords=!replace item number 8 by $slib_variant8 in $slib_tyWords |
||
361 | slib_variantie8=!char 1 to -2 of $slib_variant8 |
||
362 | slib_variantie8=$(slib_variantie8)ième |
||
363 | slib_tyWordsOrd=!replace item number 8 by $slib_variantie8 in $slib_tyWordsOrd |
||
16165 | bpr | 364 | slib_var1=!listcomplement 8 in $slib_var1 |
365 | slib_var2=$slib_var2,8 |
||
366 | slib_var3= |
||
367 | !endif |
||
16169 | bpr | 368 | !if $slib_variant9!=$empty |
369 | slib_tyWords=!replace item number 9 by $slib_variant9 in $slib_tyWords |
||
370 | slib_variantie9=!char 1 to -2 of $slib_variant9 |
||
371 | slib_variantie9=$(slib_variantie9)ième |
||
372 | slib_tyWordsOrd=!replace item number 9 by $slib_variantie9 in $slib_tyWordsOrd |
||
16165 | bpr | 373 | slib_var1=!listcomplement 9 in $slib_var1 |
374 | slib_var2=$slib_var2,9 |
||
375 | !endif |
||
376 | slib_var2=!sort list $slib_var2 |
||
15638 | reyssat | 377 | !! mark for french plural (so we can use $s) |
15626 | reyssat | 378 | s=s |
15638 | reyssat | 379 | |
15639 | bpr | 380 | !! join words with space character (traditional french rule) or - sign (1990 french "new spelling" rule) |
15626 | reyssat | 381 | !if $slib_rule issamecase trad |
15639 | bpr | 382 | tiret=$ $ |
15626 | reyssat | 383 | !else |
384 | tiret=- |
||
15639 | bpr | 385 | !endif |
15638 | reyssat | 386 | et=$(tiret)et$tiret |
15626 | reyssat | 387 | |
388 | !for slib_number in $slib_data |
||
15638 | reyssat | 389 | !! Zero and small ordinals (<=4) treated first separately. |
390 | !! If the value is zero then the cardinal number in words is 'zero' (ordinal is 'zéro-ième') |
||
15626 | reyssat | 391 | !! and no other rules apply. |
392 | !if $slib_number==0 |
||
393 | !if $slib_type issamecase ord |
||
15638 | reyssat | 394 | slib_combined=zéro-ième |
15626 | reyssat | 395 | !else |
15638 | reyssat | 396 | slib_combined=zéro |
15626 | reyssat | 397 | !endif |
398 | !else |
||
399 | !if $[$slib_number]<5 and ($slib_type issamecase ord) |
||
400 | !if $slib_fden issamecase no |
||
15639 | bpr | 401 | slib_ordinals=premier,deuxième,troisième,quatrième |
15626 | reyssat | 402 | !else |
15639 | bpr | 403 | slib_ordinals=unième,demi,tiers,quart |
15626 | reyssat | 404 | !endif |
405 | slib_combined=!column $slib_number of $slib_ordinals |
||
406 | |||
15638 | reyssat | 407 | !else !! GENERAL CASE of slib_number, neither 0 nor small ordinal |
15639 | bpr | 408 | |
15638 | reyssat | 409 | !! Three Digit Rule. |
410 | !! The integer value is split into groups of three digits starting from the right-hand side. |
||
411 | !! Once converted to text, the three-digit groups are recombined with the addition |
||
412 | !! of the relevant scale number (mille, million, milliard). |
||
15639 | bpr | 413 | |
15638 | reyssat | 414 | !! First, split in groups of 3 starting from right |
415 | !reset slib_3digitsGroups |
||
416 | !for slib_scale= 1 to 4 |
||
417 | slib_3digits=!char -3 to -1 of $slib_number |
||
418 | slib_3digitsGroups=!append item $slib_3digits to $slib_3digitsGroups |
||
419 | slib_number=!char 1 to -4 of $slib_number |
||
420 | !next |
||
15639 | bpr | 421 | |
15638 | reyssat | 422 | !! Each set of three digits is then processed individually as a number of hundreds, tens and units. |
423 | !! flag slib_endOfNb to mark if we the current digit is the last non zero one in the whole number |
||
424 | !! (to know if we add 'ième' here to ordinal number) |
||
425 | slib_endOfNb=yes |
||
426 | !reset slib_textGroups |
||
427 | !for slib_scale= 1 to 4 |
||
428 | slib_3digits=!column $slib_scale of $slib_3digitsGroups |
||
429 | !if $slib_3digits > 99 |
||
430 | slib_hundreds=!char -3 of $slib_3digits |
||
431 | !else |
||
432 | slib_hundreds=0 |
||
433 | !endif |
||
434 | slib_tensUnits=!char -2 to -1 of $slib_3digits |
||
435 | slib_tens=!char -2 of $slib_3digits |
||
15626 | reyssat | 436 | |
15638 | reyssat | 437 | !! due to french oddity : 78 = 60 + 18 , 93 = 80 + 13 |
16165 | bpr | 438 | !if $[$slib_tens] isin $slib_var1 |
15638 | reyssat | 439 | slib_tU=$[$slib_tensUnits-10*($slib_tens-1)] |
440 | !else |
||
441 | slib_tU=$slib_tensUnits |
||
442 | !endif |
||
443 | slib_units=!char -1 of $slib_3digits |
||
15639 | bpr | 444 | |
15638 | reyssat | 445 | !! Hundreds Rules. |
446 | !! If the hundreds portion of a three-digit group is not zero |
||
447 | !! the number of hundreds is added as a word (except if it is 1) |
||
448 | !! and then the word 'cent/cents/centième (depending on singular/plural/ordinal) |
||
449 | !reset slib_3digitsText |
||
15639 | bpr | 450 | |
15638 | reyssat | 451 | !if ($slib_type issamecase ord) and ($slib_endOfNb issamecase yes) and ($[$slib_tensUnits]==0) |
452 | slib_centType=centième |
||
453 | slib_centsType=centième |
||
454 | slib_endOfNb=no |
||
455 | !else |
||
456 | slib_centType=cent |
||
457 | slib_centsType=cents |
||
458 | !endif |
||
15639 | bpr | 459 | |
15638 | reyssat | 460 | !if $slib_hundreds!=0 |
461 | slib_3digitsText = !column $slib_hundreds of $slib_smallNumbers |
||
462 | !if $slib_hundreds==1 |
||
463 | !if $slib_tensUnits>0 |
||
464 | slib_3digitsText = cent$tiret |
||
15639 | bpr | 465 | !else |
15638 | reyssat | 466 | slib_3digitsText = $slib_centType |
467 | !endif |
||
468 | !else |
||
469 | !if $slib_tensUnits>0 |
||
470 | slib_3digitsText = $slib_3digitsText$(tiret)cent$tiret |
||
471 | !else |
||
472 | slib_3digitsText = $slib_3digitsText$(tiret)$slib_centsType |
||
473 | !endif |
||
474 | !endif |
||
475 | !endif |
||
15639 | bpr | 476 | |
15638 | reyssat | 477 | !! Tens Rules. |
478 | !! If the tens section of a three-digit group is two or higher, |
||
479 | !! the appropriate '-ty' word (vingt, trente, etc.) is added |
||
480 | !! to the text and followed by the name of the third digit |
||
481 | !! (unless the third digit is a zero, which is ignored, but for 70, 90, the 'third digit' is dix)). |
||
15639 | bpr | 482 | !! French oddity : add 'et' between tens and units when units=1, except if tens=8 (vingt-et-un, quatre-vingt-un) |
483 | !! Similar rule for 71 |
||
484 | !! French oddity : quatre-vingts with s iff nothing after. |
||
15638 | reyssat | 485 | !! If the tens and the units are both zero, no text is added. |
15639 | bpr | 486 | !! 7x and 9x are treated differently. |
15638 | reyssat | 487 | !! For any other value, the name of the one or two-digit number |
488 | !! is added as a special case. |
||
15626 | reyssat | 489 | |
15638 | reyssat | 490 | !! _tyWord ends differently if ordinal number without unit 'digit' |
16168 | bpr | 491 | !if ($slib_type issamecase ord) and ($slib_endOfNb issamecase yes) and ($slib_units==0) and ($slib_tens isin $slib_var2) |
15638 | reyssat | 492 | slib_tyWordsType=$slib_tyWordsOrd |
493 | slib_endOfNb=no |
||
494 | !else |
||
495 | slib_tyWordsType=$slib_tyWords |
||
496 | !endif |
||
15639 | bpr | 497 | |
15638 | reyssat | 498 | !if ($slib_type issamecase ord) and ($slib_endOfNb issamecase yes) |
499 | slib_smallNumbersType=$slib_smallNumbersOrd |
||
500 | slib_endOfNb=no |
||
501 | !else |
||
502 | slib_smallNumbersType=$slib_smallNumbers |
||
503 | !endif |
||
15639 | bpr | 504 | |
16165 | bpr | 505 | !if $slib_tens>=2 |
15638 | reyssat | 506 | slib_tyWord=!column $slib_tens of $slib_tyWordsType |
507 | slib_3digitsText= $slib_3digitsText$slib_tyWord |
||
16165 | bpr | 508 | !if $[$slib_tens] isin $slib_var2 |
15638 | reyssat | 509 | !if $slib_units!= 0 |
510 | slib_unitWord=!column $slib_units of $slib_smallNumbersType |
||
16165 | bpr | 511 | !if $slib_units>1 or $slib_tens==$slib_var3 |
15638 | reyssat | 512 | slib_3digitsText=$slib_3digitsText-$slib_unitWord |
513 | !else |
||
514 | slib_3digitsText=$slib_3digitsText$et$slib_unitWord |
||
515 | !endif |
||
516 | !endif |
||
16168 | bpr | 517 | !if ($slib_tensUnits==$[$slib_var3*10]) and ($slib_type==card) and ($slib_scale==1) |
15638 | reyssat | 518 | slib_3digitsText=$slib_3digitsText$s |
15639 | bpr | 519 | !endif |
16165 | bpr | 520 | !else !! donc slib_tens vaut 7 ou 9 en general |
15638 | reyssat | 521 | !if $[$slib_tensUnits]!= 0 |
522 | slib_tenUnitWord=!column $slib_tU of $slib_smallNumbersType |
||
523 | !if $[$slib_tensUnits]==71 |
||
524 | slib_tenUnitWord=$et$slib_tenUnitWord |
||
525 | slib_3digitsText=$slib_3digitsText$slib_tenUnitWord |
||
15639 | bpr | 526 | !else |
15638 | reyssat | 527 | slib_3digitsText=$slib_3digitsText-$slib_tenUnitWord |
15639 | bpr | 528 | !endif |
15638 | reyssat | 529 | !endif |
530 | !endif |
||
16165 | bpr | 531 | !else !! donc slib_tens vaut 0 ou 1 |
15638 | reyssat | 532 | slib_tenUnitWord=!column $slib_tU of $slib_smallNumbersType |
533 | slib_3digitsText= $slib_3digitsText$slib_tenUnitWord |
||
534 | !endif |
||
535 | !if $slib_3digits==000 |
||
536 | slib_3digitsText=zero |
||
537 | !endif |
||
538 | slib_textGroups=!append item $slib_3digitsText to $slib_textGroups |
||
15626 | reyssat | 539 | |
15638 | reyssat | 540 | !! if this pack of 3 digits is non zero then next packs are not at end of number (useful for ordinals) |
541 | !if $[$slib_3digits]!=0 |
||
542 | slib_endOfNb=no |
||
543 | !endif |
||
544 | !next |
||
15639 | bpr | 545 | |
15638 | reyssat | 546 | !! Recombination Rules. |
547 | !! When recombining the translated three-digit groups, |
||
548 | !! each group except the last is followed by a scale number name |
||
549 | !! unless the group is blank and therefore not included at all. |
||
15639 | bpr | 550 | |
15638 | reyssat | 551 | slib_endOfNb=yes |
552 | slib_combined = !column 1 of $slib_textGroups |
||
553 | !if $slib_combined=zero |
||
554 | slib_combined= |
||
555 | !endif |
||
556 | slib_3digits=!column 1 of $slib_3digitsGroups |
||
557 | !if $[$slib_3digits]>0 |
||
558 | slib_endOfNb=no |
||
559 | !endif |
||
560 | !for slib_scale = 2 to 4 |
||
561 | slib_3digits=!column $slib_scale of $slib_3digitsGroups |
||
562 | !if $[$slib_3digits]!=0 |
||
15639 | bpr | 563 | !! do we use cardinal or ordinal scale number name (mille/millième, ...) ? |
564 | !if ($slib_endOfNb issamecase yes) and ($slib_type issamecase ord) |
||
15638 | reyssat | 565 | slib_scaleNumbersType=$slib_scaleNumbersOrd |
566 | slib_endOfNb=no |
||
567 | !else |
||
568 | slib_scaleNumbersType=$slib_scaleNumbers |
||
569 | !endif |
||
15626 | reyssat | 570 | slib_3digitsText=!column $slib_scale of $slib_textGroups |
16165 | bpr | 571 | slib_scaleNumber=!column $slib_scale of $slib_scaleNumbersType |
15638 | reyssat | 572 | !if $[$slib_3digits]==1 |
573 | !if $slib_scale=2 |
||
574 | slib_prefix = $slib_scaleNumber |
||
575 | !else |
||
576 | !if ($slib_type issamecase ord) and ($slib_scaleNumbersType issamecase $slib_scaleNumbersOrd) |
||
577 | slib_prefix = $slib_scaleNumber |
||
578 | !else |
||
579 | slib_prefix = un$tiret$slib_scaleNumber |
||
580 | !endif |
||
581 | !endif |
||
582 | !else |
||
583 | slib_prefix = $slib_3digitsText$tiret$slib_scaleNumber |
||
15639 | bpr | 584 | !! add plural mark to scale number |
15638 | reyssat | 585 | !if ($slib_scale notsamecase 2) and ($slib_scaleNumbersType notsamecase $slib_scaleNumbersOrd) |
586 | slib_prefix = $slib_prefix$s |
||
587 | !endif |
||
588 | !endif |
||
589 | slib_empty=!charcnt $slib_combined |
||
590 | !if $slib_empty!=0 |
||
591 | slib_prefix=$slib_prefix$tiret |
||
592 | !endif |
||
593 | slib_combined=$slib_prefix$slib_combined |
||
594 | !endif |
||
595 | !if $[$slib_3digits] > 0 |
||
596 | slib_endOfNb=no |
||
597 | !endif |
||
598 | !next slib_scale |
||
599 | !endif |
||
600 | !endif (slib_number==0?) |
||
601 | |||
602 | !! if plural of ordinal, add s |
||
603 | !if ($slib_plural issamecase yes) and ($slib_type issamecase ord) |
||
604 | slib_dc=!char -1 of $slib_combined |
||
605 | !if $slib_dc notsamecase s |
||
606 | slib_combined=$slib_combined$s |
||
607 | !endif |
||
15626 | reyssat | 608 | !endif |
609 | slib_out=!append item $slib_combined to $slib_out |
||
15638 | reyssat | 610 | !next slib_number |
16172 | bpr | 611 | !reset slib_variant7 slib_variant8 slib_variant9 |
15638 | reyssat | 612 | !goto end |
15626 | reyssat | 613 | !endif |
14529 | czzmrn | 614 | :end |