Subversion Repositories wimsdev

Rev

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