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);
116 $hundreds = ($hundreds ?
' '.$list1[$hundreds].
' '.$langs->transnoentities(
'hundred').($hundreds == 1 ?
'' :
's').
' ' :
'');
117 $tens = (int) ((
int) $num_levels[$i] % 100);
120 $tens = ($tens ?
' '.$list1[$tens].
' ' :
'');
122 $tsd = (int) ($tens / 10);
123 $usd = (int) ($tens % 10);
127 $tenWord = trim($list1[10]);
128 if ($usd > 0 && ($tsd == 7 || $tsd == 9) && $tenWord !==
'' && strpos(trim($list2[$tsd]), $tenWord) !==
false) {
130 $baseWord = trim($list2[$tsd - 1]);
132 if (substr($baseWord, -1) ===
's') {
133 $baseWord = substr($baseWord, 0, -1);
135 $tens =
' '.$baseWord.
' ';
136 $singles =
' '.$list1[10 + $usd].
' ';
138 $tens =
' '.$list2[$tsd].
' ';
139 $singles =
' '.$list1[$usd].
' ';
142 $words[] = $hundreds.$tens.$singles.(($levels && (int) ($num_levels[$i])) ?
' '.$list3[$levels].
' ' :
'');
144 $commas = count($words);
148 $concatWords = implode(
' ', $words);
150 $concatWords = trim(preg_replace(
'/[ ]+/',
' ', $concatWords));
152 if (!empty($currency)) {
153 $concatWords .=
' '.$currency;
157 $tmptab = explode(
'.', number_format((
float) abs($numbackup), 2,
'.',
''));
158 $cents = isset($tmptab[1]) ? (int) $tmptab[1] : 0;
161 if (!empty($currency)) {
162 $concatWords .=
' '.$langs->transnoentities(
'and');
165 $concatWords .=
' '.dol_convertToWord((
float) $cents, $langs,
'',
false);
166 if (!empty($currency)) {
167 $concatWords .=
' '.$langs->transnoentities(
'centimes');
195 $sep = $reform ?
'-' :
' ';
196 $etjoin = $reform ?
'-et-' :
' et ';
199 'zéro',
'un',
'deux',
'trois',
'quatre',
'cinq',
'six',
'sept',
'huit',
'neuf',
200 'dix',
'onze',
'douze',
'treize',
'quatorze',
'quinze',
'seize',
201 'dix-sept',
'dix-huit',
'dix-neuf'
203 $tensmap = array(2 =>
'vingt', 3 =>
'trente', 4 =>
'quarante', 5 =>
'cinquante', 6 =>
'soixante');
204 $scales = array(
'',
'mille',
'million',
'milliard',
'billion',
'billiard',
'trillion');
207 $below100 =
function (
int $m) use ($units, $tensmap, $etjoin):
string {
209 return $units[$m] ??
'';
213 if ($t == 7 || $t == 9) {
215 $base = ($t == 7) ?
'soixante' :
'quatre-vingt';
216 if ($t == 7 && $u == 1) {
217 return $base.$etjoin.$units[10 + $u];
219 return $base.
'-'.$units[10 + $u];
223 return ($u == 0) ?
'quatre-vingts' :
'quatre-vingt-'.$units[$u];
226 $w = $tensmap[$t] ??
'';
231 return $w.$etjoin.$units[1];
233 return $w.
'-'.$units[$u];
240 $groups[] = $tmp % 1000;
241 $tmp = intdiv($tmp, 1000);
243 $ng = count($groups);
246 for ($g = $ng - 1; $g >= 0; $g--) {
251 $h = intdiv($val, 100);
257 $centplural = ($h >= 2 && $r == 0 && ($g === 0 || $g >= 2));
261 $text = ($h == 1) ?
'cent' : $units[$h].$sep.
'cent';
267 $rtext = $below100($r);
269 if ($r == 80 && $g === 1) {
270 $rtext =
'quatre-vingt';
272 $text = ($text ===
'') ? $rtext : $text.$sep.$rtext;
277 $text = ($val == 1) ?
'mille' : $text.$sep.
'mille';
278 $pieces[] = array(
'text' => $text,
'noun' =>
false);
280 $scaleword = isset($scales[$g]) ? $scales[$g] :
'';
281 if ($scaleword !==
'') {
285 $text .=
' '.$scaleword;
287 $pieces[] = array(
'text' => $text,
'noun' =>
true);
289 $pieces[] = array(
'text' => $text,
'noun' =>
false);
294 foreach ($pieces as $i => $piece) {
296 $result = $piece[
'text'];
299 $result .= ($pieces[$i - 1][
'noun'] ?
' ' : $sep).$piece[
'text'];
385 if ($numero >= 1000000000001) {
390 $strnumber = number_format($numero, 10);
391 $len = strlen($strnumber);
392 $parte_decimal =
'00';
393 for ($i = 0; $i < $len; $i++) {
394 if ($strnumber[$i] ==
'.') {
395 $parte_decimal = $strnumber[$i + 1].$strnumber[$i + 2];
401 if (((is_object($langs) && $langs->getDefaultLang(0) ==
'es_MX') || (!is_object($langs) && $langs ==
'es_MX')) && $numorcurrency ==
'currency') {
402 if ($numero >= 1 && $numero < 2) {
403 return (
"UN PESO ".$parte_decimal.
" / 100 M.N.");
404 } elseif ($numero >= 0 && $numero < 1) {
405 return (
"CERO PESOS ".$parte_decimal.
" / 100 M.N.");
406 } elseif ($numero >= 1000000 && $numero < 1000001) {
407 return (
"UN MILLÓN DE PESOS ".$parte_decimal.
" / 100 M.N.");
408 } elseif ($numero >= 1000000000000 && $numero < 1000000000001) {
409 return (
"UN BILLÓN DE PESOS ".$parte_decimal.
" / 100 M.N.");
413 if ($number >= 1000000000) {
414 $CdMMillon = (int) ($numero / 100000000000);
415 $numero -= $CdMMillon * 100000000000;
416 $DdMMillon = (int) ($numero / 10000000000);
417 $numero -= $DdMMillon * 10000000000;
418 $UdMMillon = (int) ($numero / 1000000000);
419 $numero -= $UdMMillon * 1000000000;
420 $entexto .=
hundreds2text($CdMMillon, $DdMMillon, $UdMMillon);
427 if ($number >= 1000000) {
428 $CdMILLON = (int) ($numero / 100000000);
429 $numero -= $CdMILLON * 100000000;
430 $DdMILLON = (int) ($numero / 10000000);
431 $numero -= $DdMILLON * 10000000;
432 $udMILLON = (int) ($numero / 1000000);
433 $numero -= $udMILLON * 1000000;
435 if (!$CdMMillon && !$DdMMillon && !$UdMMillon && !$CdMILLON && !$DdMILLON && $udMILLON == 1) {
436 $entexto .=
" MILLÓN ";
438 $entexto .=
" MILLONES ";
442 if ($number >= 1000) {
443 $cdm = (int) ($numero / 100000);
444 $numero -= $cdm * 100000;
445 $ddm = (int) ($numero / 10000);
446 $numero -= $ddm * 10000;
447 $udm = (int) ($numero / 1000);
448 $numero -= $udm * 1000;
450 if ($cdm || $ddm || $udm) {
458 $c = (int) ($numero / 100);
460 $d = (int) ($numero / 10);
461 $u = (int) $numero - $d * 10;
463 if (!$cdm && !$ddm && !$udm && !
$c && !$d && !$u && $number > 1000000) {
466 $entexto .=
" PESOS ".$parte_decimal.
" / 100 M.N.";