48 $langcode = $langs->getDefaultLang(0);
49 if (preg_match(
'/^fr/i', (
string) $langcode)) {
56 $concatWords = $langs->getLabelFromNumber((
string) $num, $currency);
59 $TNum = explode(
'.', (
string) $num);
61 $num = abs((
int) $TNum[0]);
65 $langs->transnoentitiesnoconv(
'one'),
66 $langs->transnoentitiesnoconv(
'two'),
67 $langs->transnoentitiesnoconv(
'three'),
68 $langs->transnoentitiesnoconv(
'four'),
69 $langs->transnoentitiesnoconv(
'five'),
70 $langs->transnoentitiesnoconv(
'six'),
71 $langs->transnoentitiesnoconv(
'seven'),
72 $langs->transnoentitiesnoconv(
'eight'),
73 $langs->transnoentitiesnoconv(
'nine'),
74 $langs->transnoentitiesnoconv(
'ten'),
75 $langs->transnoentitiesnoconv(
'eleven'),
76 $langs->transnoentitiesnoconv(
'twelve'),
77 $langs->transnoentitiesnoconv(
'thirteen'),
78 $langs->transnoentitiesnoconv(
'fourteen'),
79 $langs->transnoentitiesnoconv(
'fifteen'),
80 $langs->transnoentitiesnoconv(
'sixteen'),
81 $langs->transnoentitiesnoconv(
'seventeen'),
82 $langs->transnoentitiesnoconv(
'eighteen'),
83 $langs->transnoentitiesnoconv(
'nineteen')
87 $langs->transnoentitiesnoconv(
'ten'),
88 $langs->transnoentitiesnoconv(
'twenty'),
89 $langs->transnoentitiesnoconv(
'thirty'),
90 $langs->transnoentitiesnoconv(
'forty'),
91 $langs->transnoentitiesnoconv(
'fifty'),
92 $langs->transnoentitiesnoconv(
'sixty'),
93 $langs->transnoentitiesnoconv(
'seventy'),
94 $langs->transnoentitiesnoconv(
'eighty'),
95 $langs->transnoentitiesnoconv(
'ninety'),
96 $langs->transnoentitiesnoconv(
'hundred')
100 $langs->transnoentitiesnoconv(
'thousand'),
101 $langs->transnoentitiesnoconv(
'million'),
102 $langs->transnoentitiesnoconv(
'billion'),
103 $langs->transnoentitiesnoconv(
'trillion'),
104 $langs->transnoentitiesnoconv(
'quadrillion')
107 $num_length = strlen((
string) $num);
108 $levels = (int) (($num_length + 2) / 3);
109 $max_length = $levels * 3;
110 $num = substr(
'00'.$num, -$max_length);
111 $num_levels = str_split($num, 3);
112 $nboflevels = count($num_levels);
113 for ($i = 0; $i < $nboflevels; $i++) {
115 $hundreds = (int) ((
int) $num_levels[$i] / 100);
117 $hundreds = ($hundreds ?
' '.$list1[$hundreds].
' '.$langs->transnoentities(
'hundred').
' ' :
'');
118 $tens = (int) ((
int) $num_levels[$i] % 100);
121 $tens = ($tens ?
' '.$list1[$tens].
' ' :
'');
123 $tsd = (int) ($tens / 10);
124 $usd = (int) ($tens % 10);
128 $tenWord = trim($list1[10]);
129 if ($usd > 0 && ($tsd == 7 || $tsd == 9) && $tenWord !==
'' && strpos(trim($list2[$tsd]), $tenWord) !==
false) {
131 $baseWord = trim($list2[$tsd - 1]);
133 if (substr($baseWord, -1) ===
's') {
134 $baseWord = substr($baseWord, 0, -1);
136 $tens =
' '.$baseWord.
' ';
137 $singles =
' '.$list1[10 + $usd].
' ';
139 $tens =
' '.$list2[$tsd].
' ';
140 $singles =
' '.$list1[$usd].
' ';
143 $words[] = $hundreds.$tens.$singles.(($levels && (int) ($num_levels[$i])) ?
' '.$list3[$levels].
' ' :
'');
145 $commas = count($words);
149 $concatWords = implode(
' ', $words);
151 $concatWords = trim(preg_replace(
'/[ ]+/',
' ', $concatWords));
153 if (!empty($currency)) {
154 $concatWords .=
' '.$currency;
158 $tmptab = explode(
'.', number_format((
float) abs($numbackup), 2,
'.',
''));
159 $cents = isset($tmptab[1]) ? (int) $tmptab[1] : 0;
162 if (!empty($currency)) {
163 $concatWords .=
' '.$langs->transnoentities(
'and');
166 $concatWords .=
' '.dol_convertToWord((
float) $cents, $langs,
'',
false);
167 if (!empty($currency)) {
168 $concatWords .=
' '.$langs->transnoentities(
'centimes');
196 $sep = $reform ?
'-' :
' ';
197 $etjoin = $reform ?
'-et-' :
' et ';
200 'zéro',
'un',
'deux',
'trois',
'quatre',
'cinq',
'six',
'sept',
'huit',
'neuf',
201 'dix',
'onze',
'douze',
'treize',
'quatorze',
'quinze',
'seize',
202 'dix-sept',
'dix-huit',
'dix-neuf'
204 $tensmap = array(2 =>
'vingt', 3 =>
'trente', 4 =>
'quarante', 5 =>
'cinquante', 6 =>
'soixante');
205 $scales = array(
'',
'mille',
'million',
'milliard',
'billion',
'billiard',
'trillion');
208 $below100 =
function (
int $m) use ($units, $tensmap, $etjoin):
string {
210 return $units[$m] ??
'';
214 if ($t == 7 || $t == 9) {
216 $base = ($t == 7) ?
'soixante' :
'quatre-vingt';
217 if ($t == 7 && $u == 1) {
218 return $base.$etjoin.$units[10 + $u];
220 return $base.
'-'.$units[10 + $u];
224 return ($u == 0) ?
'quatre-vingts' :
'quatre-vingt-'.$units[$u];
227 $w = $tensmap[$t] ??
'';
232 return $w.$etjoin.$units[1];
234 return $w.
'-'.$units[$u];
241 $groups[] = $tmp % 1000;
242 $tmp = intdiv($tmp, 1000);
244 $ng = count($groups);
247 for ($g = $ng - 1; $g >= 0; $g--) {
252 $h = intdiv($val, 100);
258 $centplural = ($h >= 2 && $r == 0 && ($g === 0 || $g >= 2));
262 $text = ($h == 1) ?
'cent' : $units[$h].$sep.
'cent';
268 $rtext = $below100($r);
270 if ($r == 80 && $g === 1) {
271 $rtext =
'quatre-vingt';
273 $text = ($text ===
'') ? $rtext : $text.$sep.$rtext;
278 $text = ($val == 1) ?
'mille' : $text.$sep.
'mille';
279 $pieces[] = array(
'text' => $text,
'noun' =>
false);
281 $scaleword = isset($scales[$g]) ? $scales[$g] :
'';
282 if ($scaleword !==
'') {
286 $text .=
' '.$scaleword;
288 $pieces[] = array(
'text' => $text,
'noun' =>
true);
290 $pieces[] = array(
'text' => $text,
'noun' =>
false);
295 foreach ($pieces as $i => $piece) {
297 $result = $piece[
'text'];
300 $result .= ($pieces[$i - 1][
'noun'] ?
' ' : $sep).$piece[
'text'];
386 if ($numero >= 1000000000001) {
391 $strnumber = number_format($numero, 10);
392 $len = strlen($strnumber);
393 $parte_decimal =
'00';
394 for ($i = 0; $i < $len; $i++) {
395 if ($strnumber[$i] ==
'.') {
396 $parte_decimal = $strnumber[$i + 1].$strnumber[$i + 2];
402 if (((is_object($langs) && $langs->getDefaultLang(0) ==
'es_MX') || (!is_object($langs) && $langs ==
'es_MX')) && $numorcurrency ==
'currency') {
403 if ($numero >= 1 && $numero < 2) {
404 return (
"UN PESO ".$parte_decimal.
" / 100 M.N.");
405 } elseif ($numero >= 0 && $numero < 1) {
406 return (
"CERO PESOS ".$parte_decimal.
" / 100 M.N.");
407 } elseif ($numero >= 1000000 && $numero < 1000001) {
408 return (
"UN MILLÓN DE PESOS ".$parte_decimal.
" / 100 M.N.");
409 } elseif ($numero >= 1000000000000 && $numero < 1000000000001) {
410 return (
"UN BILLÓN DE PESOS ".$parte_decimal.
" / 100 M.N.");
414 if ($number >= 1000000000) {
415 $CdMMillon = (int) ($numero / 100000000000);
416 $numero -= $CdMMillon * 100000000000;
417 $DdMMillon = (int) ($numero / 10000000000);
418 $numero -= $DdMMillon * 10000000000;
419 $UdMMillon = (int) ($numero / 1000000000);
420 $numero -= $UdMMillon * 1000000000;
421 $entexto .=
hundreds2text($CdMMillon, $DdMMillon, $UdMMillon);
428 if ($number >= 1000000) {
429 $CdMILLON = (int) ($numero / 100000000);
430 $numero -= $CdMILLON * 100000000;
431 $DdMILLON = (int) ($numero / 10000000);
432 $numero -= $DdMILLON * 10000000;
433 $udMILLON = (int) ($numero / 1000000);
434 $numero -= $udMILLON * 1000000;
436 if (!$CdMMillon && !$DdMMillon && !$UdMMillon && !$CdMILLON && !$DdMILLON && $udMILLON == 1) {
437 $entexto .=
" MILLÓN ";
439 $entexto .=
" MILLONES ";
443 if ($number >= 1000) {
444 $cdm = (int) ($numero / 100000);
445 $numero -= $cdm * 100000;
446 $ddm = (int) ($numero / 10000);
447 $numero -= $ddm * 10000;
448 $udm = (int) ($numero / 1000);
449 $numero -= $udm * 1000;
451 if ($cdm || $ddm || $udm) {
459 $c = (int) ($numero / 100);
461 $d = (int) ($numero / 10);
462 $u = (int) $numero - $d * 10;
464 if (!$cdm && !$ddm && !$udm && !
$c && !$d && !$u && $number > 1000000) {
467 $entexto .=
" PESOS ".$parte_decimal.
" / 100 M.N.";