Source for file lang.fr.php
Documentation is available at lang.fr.php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2003 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Kouber Saparev <kouber@saparev.com> |
// +----------------------------------------------------------------------+
// $Id: lang.fr.php,v 1.3 2004/09/02 11:07:59 makler Exp $
require_once("Numbers/Words.php");
* Class for translating numbers into French.
* @author Kouber Saparev <kouber@saparev.com>
* Language name in English.
* The words for some numbers.
var $_misc_numbers = array (
* The words for digits (except zero).
var $_digits = array (1=> "un", "deux", "trois", "quatre", "cinq", "six", "sept", "huit", "neuf");
var $_infinity = 'infini';
* The word for the "and" language construct.
* The word for the minus sign.
var $_minus = 'moins'; // minus sign
* The plural suffix (except for hundred).
var $_plural = 's'; // plural suffix
* The suffixes for exponents (singular).
45 => 'quattuordecillion',
75 => 'quattuorvigintillion',
78 => 'quinvigintillion',
84 => 'septenvigintillion',
87 => 'octovigintillion',
90 => 'novemvigintillion',
99 => 'duotrigintillion',
102 => 'trestrigintillion',
105 => 'quattuortrigintillion',
108 => 'quintrigintillion',
111 => 'sextrigintillion',
114 => 'septentrigintillion',
117 => 'octotrigintillion',
120 => 'novemtrigintillion',
123 => 'quadragintillion',
126 => 'unquadragintillion',
129 => 'duoquadragintillion',
132 => 'trequadragintillion',
135 => 'quattuorquadragintillion',
138 => 'quinquadragintillion',
141 => 'sexquadragintillion',
144 => 'septenquadragintillion',
147 => 'octoquadragintillion',
150 => 'novemquadragintillion',
153 => 'quinquagintillion',
156 => 'unquinquagintillion',
159 => 'duoquinquagintillion',
162 => 'trequinquagintillion',
165 => 'quattuorquinquagintillion',
168 => 'quinquinquagintillion',
171 => 'sexquinquagintillion',
174 => 'septenquinquagintillion',
177 => 'octoquinquagintillion',
180 => 'novemquinquagintillion',
186 => 'unsexagintillion',
189 => 'duosexagintillion',
192 => 'tresexagintillion',
195 => 'quattuorsexagintillion',
198 => 'quinsexagintillion',
201 => 'sexsexagintillion',
204 => 'septensexagintillion',
207 => 'octosexagintillion',
210 => 'novemsexagintillion',
213 => 'septuagintillion',
216 => 'unseptuagintillion',
219 => 'duoseptuagintillion',
222 => 'treseptuagintillion',
225 => 'quattuorseptuagintillion',
228 => 'quinseptuagintillion',
231 => 'sexseptuagintillion',
234 => 'septenseptuagintillion',
237 => 'octoseptuagintillion',
240 => 'novemseptuagintillion',
246 => 'unoctogintillion',
249 => 'duooctogintillion',
252 => 'treoctogintillion',
255 => 'quattuoroctogintillion',
258 => 'quinoctogintillion',
261 => 'sexoctogintillion',
264 => 'septoctogintillion',
267 => 'octooctogintillion',
270 => 'novemoctogintillion',
276 => 'unnonagintillion',
279 => 'duononagintillion',
282 => 'trenonagintillion',
285 => 'quattuornonagintillion',
288 => 'quinnonagintillion',
291 => 'sexnonagintillion',
294 => 'septennonagintillion',
297 => 'octononagintillion',
300 => 'novemnonagintillion',
* Split a number to groups of three-digit numbers.
* @param mixed $num An integer or its string representation
* @return array Groups of three-digit numbers.
* @author Kouber Saparev <kouber@saparev.com>
function _splitNumber ($num)
$first = substr($num, 0 , $strlen%3 );
// {{{ _showDigitsGroup()
* Converts a three-digit number to its word representation
* @param integer $num An integer between 1 and 999 inclusive.
* @param boolean $last A flag, that determines if it is the last group of digits -
* this is used to accord the plural suffix of the "hundreds".
* Example: 200 = "deux cents", but 200000 = "deux cent mille".
* @return string The words for the given number.
* @author Kouber Saparev <kouber@saparev.com>
function _showDigitsGroup ($num, $last = false )
// extract the value of each digit from the three-digit number
$d = ($num- $e)%100/10; // tens
$s = ($num- $d*10- $e)%1000/100; // hundreds
// process the "hundreds" digit.
$ret .= $this->_digits[$s]. $this->_sep. $this->_misc_numbers[100 ];
if ($last && !$e && !$d) {
$ret .= $this->_misc_numbers[100 ];
// process the "tens" digit, and optionally the "ones" digit.
// in the case of 1, the "ones" digit also must be processed
$ret .= $this->_misc_numbers[10+ $e];
$ret .= $this->_misc_numbers[10 ]. '-'. $this->_digits[$e];
$ret .= $this->_misc_numbers[60 ];
$ret .= $this->_sep. $this->_and. $this->_sep;
$ret .= $this->_showDigitsGroup ($resto);
$ret .= $this->_digits[4 ]. $this->_dash. $this->_misc_numbers[20 ];
$ret .= $this->_showDigitsGroup ($resto);
$ret .= $this->_misc_numbers[$d*10 ];
// process the "ones" digit
$ret .= $this->_sep. $this->_and. $this->_sep;
$ret .= $this->_digits[$e];
// strip excessive separators
$ret = rtrim($ret, $this->_sep);
* Converts a number to its word representation
* @param integer $num An integer (or its string representation) between 9.99*-10^302
* and 9.99*10^302 (999 centillions) that need to be converted to words
* @return string The corresponding word representation
* @author Kouber Saparev <kouber@saparev.com>
// check if $num is a valid non-zero number
if (substr($num, 0 , 1 ) == '-') {
$ret = $this->_minus . $this->_sep;
// if the absolute value is greater than 9.99*10^302, return infinity
return $ret . $this->_infinity;
// strip excessive zero signs
// split $num to groups of three-digit numbers
$num_groups = $this->_splitNumber ($num);
$sizeof_numgroups = count($num_groups);
foreach ($num_groups as $i=> $number) {
// what is the corresponding exponent for the current group
$pow = $sizeof_numgroups- $i;
// skip processment for empty groups
if ($number!=1 || $pow!=2 ) {
$ret .= $this->_showDigitsGroup ($number, $i+1== $sizeof_numgroups). $this->_sep;
$ret .= $this->_exponent[($pow-1 )*3 ];
if ($pow>2 && $number>1 ) {
return rtrim($ret, $this->_sep);
Documentation generated on Mon, 11 Mar 2019 13:56:07 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|