package.xml0000644000076500007650000004576411732225115011706 0ustar igorigor Numbers_Words pear.php.net The PEAR Numbers_Words package provides methods for spelling numerals in words. With Numbers_Words class you can convert numbers written in arabic digits to words in several languages. You can convert an integer between -infinity and infinity. If your system does not support such long numbers you can call Numbers_Words::toWords() with just a string. With the Numbers_Words::toCurrency($num, $locale, 'USD') method you can convert a number (decimal and fraction part) to words with currency name. The following languages are supported: * bg (Bulgarian) by Kouber Saparev * cs (Czech) by Petr 'PePa' Pavel * de (German) by Piotr Klaban * dk (Danish) by Jesper Veggerby * en_100 (Donald Knuth system, English) by Piotr Klaban * en_GB (British English) by Piotr Klaban * en_US (American English) by Piotr Klaban * es (Spanish Castellano) by Xavier Noguer * es_AR (Argentinian Spanish) by Martin Marrese * et (Estonian) by Erkki Saarniit * fr (French) by Kouber Saparev * fr_BE (French Belgium) by Kouber Saparev and Philippe Bajoit * he (Hebrew) by Hadar Porat * hu_HU (Hungarian) by Nils Homp * id (Indonesian) by Ernas M. Jamil and Arif Rifai Dwiyanto * it_IT (Italian) by Filippo Beltramini and Davide Caironi * lt (Lithuanian) by Laurynas Butkus * nl (Dutch) by WHAM van Dinter * pl (Polish) by Piotr Klaban * pt_BR (Brazilian Portuguese) by Marcelo Subtil Marcal and Mario H.C.T. * ru (Russian) by Andrey Demenev * sv (Swedish) by Robin Ericsson Piotr Klaban makler makler@man.torun.pl no Kouber Saparev kouber kouber@php.net yes Igor Feghali ifeghali ifeghali@php.net yes Marcelo Subtil Marcal msmarcal msmarcal@php.net yes Xavier Noguer xnoguer xnoguer.php@gmail.com yes Hadar Porat hadar_p hpman28@gmail.com yes 2012-03-21 0.16.4 0.16.0 beta beta PHP Currency names for Dutch Re-licensed to PHP 3.01 [ifeghali] 4.0.0 1.4.0b1 Math_BigInteger pear.php.net 0.1 0.1 beta beta 2002-11-15 PHP License This is the initial release of the Numbers_Words package. 0.2 0.2 beta beta 2002-11-19 PHP License New lang definition file for en_100 (Donald Knuth number system). 0.3 0.3 beta beta 2002-11-26 PHP License New lang files for de (German), pt_BR (Brazilian Portuguese), es (Spanish). First PEAR release. 0.4 0.4 beta beta 2003-09-17 PHP License New lang files for: ee (Estonian) and it_IT (Italian). Changes to es (extranous spaces) and Words.php (trim output, new function toCurrency() for converting currency values). 0.5 0.5 beta beta 2003-12-16 PHP License New file for Bulgarian and French language. toCurrency() method in en_US translation. 0.5.1 0.5.1 beta beta 2003-12-17 PHP License Small fix to French translation. 0.6 0.6 beta beta 2004-04-27 PHP License New file for Argentinian Spanish, Russian and Indonesian language. 0.7 0.7 beta beta 2004-04-28 PHP License New file for Swedish language. Small fix in fr and bg translations. 0.7.1 0.7.1 beta beta 2004-05-25 PHP License Small bug fix (use toWords instead of towords) for PHP version 5. 0.8 0.8 beta beta 2004-06-17 PHP License New file for Lithuanian language. Fixed a class method finding (should work for PHP5 and PHP4 now). 0.8.1 0.8.1 beta beta 2004-08-09 PHP License Fixed two bugs (missing t in 400, and wrong function call) in Russian translation. 0.9.0 0.9.0 beta beta 2004-08-26 PHP License New file for Hungarian language (Thanks to Nils Homp). 0.10.0 0.10.0 beta beta 2004-09-20 PHP License New file for Danish language (Thanks to Jesper Veggerby). 0.10.1 0.10.1 beta beta 2004-09-30 PHP License Small bug fix to German translation (the one thousand) (Thanks to neuner at futureweb dot at). 0.11.0 0.11.0 beta beta 2004-10-22 PHP License toCurrencyWords() support in pt_BR translation (Thanks to Mario H.C.T.) 0.12.0 0.12.0 beta beta 2005-01-11 PHP License New file for French (Belgium) language (Thanks to Philippe Bajoit). 0.13.0 0.13.0 beta beta 2005-02-28 PHP License New files for Czech (thanks to Petr 'PePa' Pavel) and Hebrew (thanks to Hadar Porat) languages. 0.13.1 0.13.0 beta beta 2005-03-09 PHP License Fixed a problem with no leading zero in fraction of the currency value (reported by geekdom at gmail dot com). 0.14.0 0.14.0 beta beta 2005-09-05 PHP License Fixed plural of pence (Thanks to Peter Dunham and Rob King). Added toCurrency method to en_GB language file. Fraction part can be written in digits (Thanks to Rob King). 0.15.0 0.15.0 beta beta 2006-06-13 PHP License * New file for Dutch language (Thanks to WHAM van Dinter); * package.xml updated to version 2.0; * Bugs fixed: - #5618 locale name (and file name) for Estonian is changed from ee to et; - #6654 bug in Russian translation; * New feature added: - #7339 new Numbers_Words::getLocales() method is available (Thanks to Bertrand Gugger). 0.16.0 0.16.0 beta beta 2009-03-10 PHP License * Added numerous language unit tests (Bulgarian, English 100, English GB, English US, French, French Belgium, German, Italian, Portuguese Brazilian); * Swap all tests to PHPUnit 3; * Bugs fixed: - #10744 wrong getLocales() Docblock; - #14988 bogus non-int parsing; - #14667 bad trascription for 101 numbers and 102 thousands bug; - incorrect values for 80 and 81 in French Belgium; - #15260 uninitialized string offset in Brazilian Portuguese. 0.16.1 0.16.0 beta beta 2010-02-15 PHP License * Clean up package definition and tests; * Better cast/sanitation of non-integer values; * Fixed bug #16019 (incorrect trimming of vowels in the Italian extension). 0.16.2 0.16.0 beta beta 2010-05-10 PHP License * Fixed bug #16435 (improper use of substr() in Polish extension); * Fixed bug #16667 (wrong spelling of 40 in Hungarian extension) (Vlajos); * Fixed bug #16733 (incorrect rounding of cents); * Added optional dependency on Math_BigInteger; * Improved unit tests (Daniel O'Connor). 0.16.3 0.16.0 beta beta 2011-12-11 PHP License QA Release Bug #12512 Windows incorrect declaration of toWords() in lang.fr.php (and others!) ifeghali Bug #17373 bug in toWords function for hungarian translation kouber Bug #17392 bugs in toWords function for hungarian translation ifeghali Bug #17754 Patch: Using explode instead of split ifeghali Request #17763 Independent tr_TR Lang support ifeghali Bug #17794 Patch: avoiding split in es_MX file ifeghali Bug #18501 incorrect declaration of toWords() in lang.fr.php kouber Bug #19013 remove error_reporting (for PEAR QA team) ifeghali 0.16.4 0.16.0 beta beta 2012-03-20 PHP Currency names for Dutch Re-licensed to PHP 3.01 [ifeghali] Numbers_Words-0.16.4/Numbers/Words.php0000644000076500007650000002042011732225114016305 0ustar igorigor * * @category Numbers * @package Numbers_Words * @author Piotr Klaban * @license PHP 3.01 http://www.php.net/license/3_01.txt * @version SVN: $Id$ * @link http://pear.php.net/package/Numbers_Words */ // {{{ Numbers_Words /** * The Numbers_Words class provides method to convert arabic numerals to words. * * @category Numbers * @package Numbers_Words * @author Piotr Klaban * @license PHP 3.01 http://www.php.net/license/3_01.txt * @link http://pear.php.net/package/Numbers_Words * @since PHP 4.2.3 * @access public */ class Numbers_Words { // {{{ properties /** * Default Locale name * @var string * @access public */ var $locale = 'en_US'; // }}} // {{{ toWords() /** * Converts a number to its word representation * * @param integer $num An integer between -infinity and infinity inclusive :) * that should be converted to a words representation * @param string $locale Language name abbreviation. Optional. Defaults to * current loaded driver or en_US if any. * @param array $options Specific driver options * * @access public * @author Piotr Klaban * @since PHP 4.2.3 * @return string The corresponding word representation */ function toWords($num, $locale = '', $options = array()) { if (empty($locale)) { $locale = $this->locale; } if (empty($locale)) { $locale = 'en_US'; } require_once "Numbers/Words/lang.${locale}.php"; $classname = "Numbers_Words_${locale}"; if (!class_exists($classname)) { return Numbers_Words::raiseError("Unable to include the Numbers/Words/lang.${locale}.php file"); } $methods = get_class_methods($classname); if (!in_array('_toWords', $methods) && !in_array('_towords', $methods)) { return Numbers_Words::raiseError("Unable to find _toWords method in '$classname' class"); } if (!is_int($num)) { // cast (sanitize) to int without losing precision $num = preg_replace('/^[^\d]*?(-?)[ \t\n]*?(\d+)([^\d].*?)?$/', '$1$2', $num); } $truth_table = ($classname == get_class($this)) ? 'T' : 'F'; $truth_table .= (empty($options)) ? 'T' : 'F'; switch ($truth_table) { /** * We are a language driver */ case 'TT': return trim($this->_toWords($num)); break; /** * We are a language driver with custom options */ case 'TF': return trim($this->_toWords($num, $options)); break; /** * We are the parent class */ case 'FT': @$obj = new $classname; return trim($obj->_toWords($num)); break; /** * We are the parent class and should pass driver options */ case 'FF': @$obj = new $classname; return trim($obj->_toWords($num, $options)); break; } } // }}} // {{{ toCurrency() /** * Converts a currency value to word representation (1.02 => one dollar two cents) * If the number has not any fraction part, the "cents" number is omitted. * * @param float $num A float/integer/string number representing currency value * * @param string $locale Language name abbreviation. Optional. Defaults to en_US. * * @param string $int_curr International currency symbol * as defined by the ISO 4217 standard (three characters). * E.g. 'EUR', 'USD', 'PLN'. Optional. * Defaults to $def_currency defined in the language class. * * @return string The corresponding word representation * * @access public * @author Piotr Klaban * @since PHP 4.2.3 * @return string */ function toCurrency($num, $locale = 'en_US', $int_curr = '') { $ret = $num; @include_once "Numbers/Words/lang.${locale}.php"; $classname = "Numbers_Words_${locale}"; if (!class_exists($classname)) { return Numbers_Words::raiseError("Unable to include the Numbers/Words/lang.${locale}.php file"); } $methods = get_class_methods($classname); if (!in_array('toCurrencyWords', $methods) && !in_array('tocurrencywords', $methods)) { return Numbers_Words::raiseError("Unable to find toCurrencyWords method in '$classname' class"); } @$obj = new $classname; // round if a float is passed, use Math_BigInteger otherwise if (is_float($num)) { $num = round($num, 2); } if (strpos($num, '.') === false) { return trim($obj->toCurrencyWords($int_curr, $num)); } $currency = explode('.', $num, 2); $len = strlen($currency[1]); if ($len == 1) { // add leading zero $currency[1] .= '0'; } elseif ($len > 2) { // get the 3rd digit after the comma $round_digit = substr($currency[1], 2, 1); // cut everything after the 2nd digit $currency[1] = substr($currency[1], 0, 2); if ($round_digit >= 5) { // round up without losing precision include_once "Math/BigInteger.php"; $int = new Math_BigInteger(join($currency)); $int = $int->add(new Math_BigInteger(1)); $int_str = $int->toString(); $currency[0] = substr($int_str, 0, -2); $currency[1] = substr($int_str, -2); // check if the rounded decimal part became zero if ($currency[1] == '00') { $currency[1] = false; } } } return trim($obj->toCurrencyWords($int_curr, $currency[0], $currency[1])); } // }}} // {{{ getLocales() /** * Lists available locales for Numbers_Words * * @param mixed $locale string/array of strings $locale * Optional searched language name abbreviation. * Default: all available locales. * * @return array The available locales (optionaly only the requested ones) * @author Piotr Klaban * @author Bertrand Gugger, bertrand at toggg dot com * * @access public * @static * @return mixed[] */ function getLocales($locale = null) { $ret = array(); if (isset($locale) && is_string($locale)) { $locale = array($locale); } $dname = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Words' . DIRECTORY_SEPARATOR; $dh = opendir($dname); if ($dh) { while ($fname = readdir($dh)) { if (preg_match('#^lang\.([a-z_]+)\.php$#i', $fname, $matches)) { if (is_file($dname . $fname) && is_readable($dname . $fname) && (!isset($locale) || in_array($matches[1], $locale))) { $ret[] = $matches[1]; } } } closedir($dh); sort($ret); } return $ret; } // }}} // {{{ raiseError() /** * Trigger a PEAR error * * To improve performances, the PEAR.php file is included dynamically. * * @param string $msg error message * * @return PEAR_Error */ function raiseError($msg) { include_once 'PEAR.php'; return PEAR::raiseError($msg); } // }}} } // }}} Numbers_Words-0.16.4/Numbers/Words/lang.bg.php0000644000076500007650000003743411732225114017632 0ustar igorigor * @license PHP 3.01 http://www.php.net/license/3_01.txt * @version SVN: $Id$ * @link http://pear.php.net/package/Numbers_Words */ /** * Include needed files */ require_once "Numbers/Words.php"; /** * Class for translating numbers into Bulgarian. * * @category Numbers * @package Numbers_Words * @author Kouber Saparev * @license PHP 3.01 http://www.php.net/license/3_01.txt * @link http://pear.php.net/package/Numbers_Words */ class Numbers_Words_bg extends Numbers_Words { // {{{ properties /** * Locale name. * @var string * @access public */ var $locale = 'bg'; /** * Language name in English. * @var string * @access public */ var $lang = 'Bulgarian'; /** * Native language name. * @var string * @access public */ var $lang_native = 'Áúëãàðñêè'; /** * Some miscellaneous words and language constructs. * @var string * @access private */ var $_misc_strings = array( 'deset'=>'äåñåò', // "ten" 'edinadeset'=>'åäèíàäåñåò', // "eleven" 'na'=>'íà', // liaison particle for 12 to 19 'sto'=>'ñòî', // "hundred" 'sta'=>'ñòà', // suffix for 2 and 3 hundred 'stotin'=>'ñòîòèí', // suffix for 4 to 9 hundred 'hiliadi'=>'õèëÿäè' // plural form of "thousand" ); /** * The words for digits (except zero). Note that, there are three genders for them (neuter, masculine and feminine). * The words for 3 to 9 (masculine) and for 2 to 9 (feminine) are the same as neuter, so they're filled * in the _initDigits() method, which is invoked from the constructor. * @var string * @access private */ var $_digits = array( 0=>array(1=>"åäíî", "äâå", "òðè", "÷åòèðè", "ïåò", "øåñò", "ñåäåì", "îñåì", "äåâåò"), // neuter 1=>array(1=>'åäèí', 'äâà'), // masculine -1=>array(1=>'åäíà') // feminine ); /** * A flag, that determines if the _digits array is filled for masculine and feminine genders. * @var string * @access private */ var $_digits_initialized = false; /** * A flag, that determines if the "and" word is placed already before the last non-empty group of digits. * @var string * @access private */ var $_last_and = false; /** * The word for zero. * @var string * @access private */ var $_zero = 'íóëà'; /** * The word for infinity. * @var string * @access private */ var $_infinity = 'áåçêðàéíîñò'; /** * The word for the "and" language construct. * @var string * @access private */ var $_and = 'è'; /** * The word separator. * @var string * @access private */ var $_sep = ' '; /** * The word for the minus sign. * @var string * @access private */ var $_minus = 'ìèíóñ'; // minus sign /** * The plural suffix (except for thousand). * @var string * @access private */ var $_plural = 'à'; // plural suffix /** * The suffixes for exponents (singular). * @var array * @access private */ var $_exponent = array( 0 => '', 3 => 'õèëÿäà', 6 => 'ìèëèîí', 9 => 'ìèëèàðä', 12 => 'òðèëèîí', 15 => 'êâàäðèëèîí', 18 => 'êâèíòèëèîí', 21 => 'ñåêñòèëèîí', 24 => 'ñåïòèëèîí', 27 => 'îêòèëèîí', 30 => 'íîíàëèîí', 33 => 'äåêàëèîí', 36 => 'óíäåêàëèîí', 39 => 'äóîäåêàëèîí', 42 => 'òðåäåêàëèîí', 45 => 'êâàòîðäåêàëèîí', 48 => 'êâèíòäåêàëèîí', 51 => 'ñåêñäåêàëèîí', 54 => 'ñåïòäåêàëèîí', 57 => 'îêòîäåêàëèîí', 60 => 'íîâåìäåêàëèîí', 63 => 'âèãèíòèëèîí', 66 => 'óíâèãèíòèëèîí', 69 => 'äóîâèãèíòèëèîí', 72 => 'òðåâèãèíòèëèîí', 75 => 'êâàòîðâèãèíòèëèîí', 78 => 'êâèíâèãèíòèëèîí', 81 => 'ñåêñâèãèíòèëèîí', 84 => 'ñåïòåíâèãèíòèëèîí', 87 => 'îêòîâèãèíòèëèîí', 90 => 'íîâåìâèãèíòèëèîí', 93 => 'òðèãèíòèëèîí', 96 => 'óíòðèãèíòèëèîí', 99 => 'äóîòðèãèíòèëèîí', 102 => 'òðåòðèãèíòèëèîí', 105 => 'êâàòîðòðèãèíòèëèîí', 108 => 'êâèíòðèãèíòèëèîí', 111 => 'ñåêñòðèãèíòèëèîí', 114 => 'ñåïòåíòðèãèíòèëèîí', 117 => 'îêòîòðèãèíòèëèîí', 120 => 'íîâåìòðèãèíòèëèîí', 123 => 'êâàäðàãèíòèëèîí', 126 => 'óíêâàäðàãèíòèëèîí', 129 => 'äóîêâàäðàãèíòèëèîí', 132 => 'òðåêâàäðàãèíòèëèîí', 135 => 'êâàòîðêâàäðàãèíòèëèîí', 138 => 'êâèíêâàäðàãèíòèëèîí', 141 => 'ñåêñêâàäðàãèíòèëèîí', 144 => 'ñåïòåíêâàäðàãèíòèëèîí', 147 => 'îêòîêâàäðàãèíòèëèîí', 150 => 'íîâåìêâàäðàãèíòèëèîí', 153 => 'êâèíêâàãèíòèëèîí', 156 => 'óíêâèíêàãèíòèëèîí', 159 => 'äóîêâèíêàãèíòèëèîí', 162 => 'òðåêâèíêàãèíòèëèîí', 165 => 'êâàòîðêâèíêàãèíòèëèîí', 168 => 'êâèíêâèíêàãèíòèëèîí', 171 => 'ñåêñêâèíêàãèíòèëèîí', 174 => 'ñåïòåíêâèíêàãèíòèëèîí', 177 => 'îêòîêâèíêàãèíòèëèîí', 180 => 'íîâåìêâèíêàãèíòèëèîí', 183 => 'ñåêñàãèíòèëèîí', 186 => 'óíñåêñàãèíòèëèîí', 189 => 'äóîñåêñàãèíòèëèîí', 192 => 'òðåñåêñàãèíòèëèîí', 195 => 'êâàòîðñåêñàãèíòèëèîí', 198 => 'êâèíñåêñàãèíòèëèîí', 201 => 'ñåêññåêñàãèíòèëèîí', 204 => 'ñåïòåíñåêñàãèíòèëèîí', 207 => 'îêòîñåêñàãèíòèëèîí', 210 => 'íîâåìñåêñàãèíòèëèîí', 213 => 'ñåïòàãèíòèëèîí', 216 => 'óíñåïòàãèíòèëèîí', 219 => 'äóîñåïòàãèíòèëèîí', 222 => 'òðåñåïòàãèíòèëèîí', 225 => 'êâàòîðñåïòàãèíòèëèîí', 228 => 'êâèíñåïòàãèíòèëèîí', 231 => 'ñåêññåïòàãèíòèëèîí', 234 => 'ñåïòåíñåïòàãèíòèëèîí', 237 => 'îêòîñåïòàãèíòèëèîí', 240 => 'íîâåìñåïòàãèíòèëèîí', 243 => 'îêòîãèíòèëèîí', 246 => 'óíîêòîãèíòèëèîí', 249 => 'äóîîêòîãèíòèëèîí', 252 => 'òðåîêòîãèíòèëèîí', 255 => 'êâàòîðîêòîãèíòèëèîí', 258 => 'êâèíîêòîãèíòèëèîí', 261 => 'ñåêñîêòîãèíòèëèîí', 264 => 'ñåïòîêòîãèíòèëèîí', 267 => 'îêòîîêòîãèíòèëèîí', 270 => 'íîâåìîêòîãèíòèëèîí', 273 => 'íîíàãèíòèëèîí', 276 => 'óííîíàãèíòèëèîí', 279 => 'äóîíîíàãèíòèëèîí', 282 => 'òðåíîíàãèíòèëèîí', 285 => 'êâàòîðíîíàãèíòèëèîí', 288 => 'êâèííîíàãèíòèëèîí', 291 => 'ñåêñíîíàãèíòèëèîí', 294 => 'ñåïòåííîíàãèíòèëèîí', 297 => 'îêòîíîíàãèíòèëèîí', 300 => 'íîâåìíîíàãèíòèëèîí', 303 => 'öåíòèëèîí' ); // }}} // {{{ Numbers_Words_bg() /** * The class constructor, used for calling the _initDigits method. * * @return void * * @access public * @author Kouber Saparev * @see function _initDigits */ function Numbers_Words_bg() { $this->_initDigits(); } // }}} // {{{ _initDigits() /** * Fills the _digits array for masculine and feminine genders with * corresponding references to neuter words (when they're the same). * * @return void * * @access private * @author Kouber Saparev */ function _initDigits() { if (!$this->_digits_initialized) { for ($i=3; $i<=9; $i++) { $this->_digits[1][$i] =& $this->_digits[0][$i]; } for ($i=2; $i<=9; $i++) { $this->_digits[-1][$i] =& $this->_digits[0][$i]; } $this->_digits_initialized = true; } } // }}} // {{{ _splitNumber() /** * Split a number to groups of three-digit numbers. * * @param mixed $num An integer or its string representation * that need to be split * * @return array Groups of three-digit numbers. * * @access private * @author Kouber Saparev * @since PHP 4.2.3 */ function _splitNumber($num) { if (is_string($num)) { $ret = array(); $strlen = strlen($num); $first = substr($num, 0, $strlen%3); preg_match_all('/\d{3}/', substr($num, $strlen%3, $strlen), $m); $ret =& $m[0]; if ($first) { array_unshift($ret, $first); } return $ret; } return explode(' ', number_format($num, 0, '', ' ')); // a faster version for integers } // }}} // {{{ _showDigitsGroup() /** * Converts a three-digit number to its word representation * in Bulgarian language. * * @param integer $num An integer between 1 and 999 inclusive. * @param integer $gender An integer which represents the gender of * the current digits group. * 0 - neuter * 1 - masculine * -1 - feminine * @param boolean $last A flag that determines if the current digits group * is the last one. * * @return string The words for the given number. * * @access private * @author Kouber Saparev */ function _showDigitsGroup($num, $gender = 0, $last = false) { /* A storage array for the return string. Positions 1, 3, 5 are intended for digit words and everything else (0, 2, 4) for "and" words. Both of the above types are optional, so the size of the array may vary. */ $ret = array(); // extract the value of each digit from the three-digit number $e = $num%10; // ones $d = ($num-$e)%100/10; // tens $s = ($num-$d*10-$e)%1000/100; // hundreds // process the "hundreds" digit. if ($s) { switch ($s) { case 1: $ret[1] = $this->_misc_strings['sto']; break; case 2: case 3: $ret[1] = $this->_digits[0][$s].$this->_misc_strings['sta']; break; default: $ret[1] = $this->_digits[0][$s].$this->_misc_strings['stotin']; } } // process the "tens" digit, and optionally the "ones" digit. if ($d) { // in the case of 1, the "ones" digit also must be processed if ($d==1) { if (!$e) { $ret[3] = $this->_misc_strings['deset']; // ten } else { if ($e==1) { $ret[3] = $this->_misc_strings['edinadeset']; // eleven } else { $ret[3] = $this->_digits[1][$e].$this->_misc_strings['na'].$this->_misc_strings['deset']; // twelve - nineteen } // the "ones" digit is alredy processed, so skip a second processment $e = 0; } } else { $ret[3] = $this->_digits[1][$d].$this->_misc_strings['deset']; // twenty - ninety } } // process the "ones" digit if ($e) { $ret[5] = $this->_digits[$gender][$e]; } // put "and" where needed if (count($ret)>1) { if ($e) { $ret[4] = $this->_and; } else { $ret[2] = $this->_and; } } // put "and" optionally in the case this is the last non-empty group if ($last) { if (!$s||count($ret)==1) { $ret[0] = $this->_and; } $this->_last_and = true; } // sort the return array so that "and" constructs go to theirs appropriate places ksort($ret); return implode($this->_sep, $ret); } // }}} // {{{ _toWords() /** * Converts a number to its word representation * in Bulgarian language. * * @param integer $num An integer 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 * * @access protected * @author Kouber Saparev * @since Numbers_Words 0.16.3 */ function _toWords($num = 0) { $ret = array(); $ret_minus = ''; // check if $num is a valid non-zero number if (!$num || preg_match('/^-?0+$/', $num) || !preg_match('/^-?\d+$/', $num)) { return $this->_zero; } // add a minus sign if (substr($num, 0, 1) == '-') { $ret_minus = $this->_minus . $this->_sep; $num = substr($num, 1); } // if the absolute value is greater than 9.99*10^302, return infinity if (strlen($num) > 306) { return $ret_minus . $this->_infinity; } // strip excessive zero signs $num = ltrim($num, '0'); // split $num to groups of three-digit numbers $num_groups = $this->_splitNumber($num); $sizeof_numgroups = count($num_groups); // go through the groups in reverse order, so that the last group could be determined for ($i=$sizeof_numgroups-1, $j=1; $i>=0; $i--, $j++) { if (!isset($ret[$j])) { $ret[$j] = ''; } // what is the corresponding exponent for the current group $pow = $sizeof_numgroups-$i; // skip processment for empty groups if ($num_groups[$i]!='000') { if ($num_groups[$i]>1) { if ($pow==1) { $ret[$j] .= $this->_showDigitsGroup($num_groups[$i], 0, !$this->_last_and && $i).$this->_sep; $ret[$j] .= $this->_exponent[($pow-1)*3]; } elseif ($pow==2) { $ret[$j] .= $this->_showDigitsGroup($num_groups[$i], -1, !$this->_last_and && $i).$this->_sep; $ret[$j] .= $this->_misc_strings['hiliadi'].$this->_sep; } else { $ret[$j] .= $this->_showDigitsGroup($num_groups[$i], 1, !$this->_last_and && $i).$this->_sep; $ret[$j] .= $this->_exponent[($pow-1)*3].$this->_plural.$this->_sep; } } else { if ($pow==1) { $ret[$j] .= $this->_showDigitsGroup($num_groups[$i], 0, !$this->_last_and && $i).$this->_sep; } elseif ($pow==2) { $ret[$j] .= $this->_exponent[($pow-1)*3].$this->_sep; } else { $ret[$j] .= $this->_digits[1][1].$this->_sep.$this->_exponent[($pow-1)*3].$this->_sep; } } } } return $ret_minus . rtrim(implode('', array_reverse($ret)), $this->_sep); } // }}} } Numbers_Words-0.16.4/Numbers/Words/lang.cs.php0000644000076500007650000002357211732225114017645 0ustar igorigor * @license PHP 3.01 http://www.php.net/license/3_01.txt * @version SVN: $Id$ * @link http://pear.php.net/package/Numbers_Words */ /** * Class for translating numbers into Czech. * * @author Petr 'PePa' Pavel * @package Numbers_Words */ /** * Include needed files */ require_once "Numbers/Words.php"; /** * Class for translating numbers into Czech. * * @category Numbers * @package Numbers_Words * @author Petr 'PePa' Pavel * @license PHP 3.01 http://www.php.net/license/3_01.txt * @link http://pear.php.net/package/Numbers_Words */ class Numbers_Words_cs extends Numbers_Words { // {{{ properties /** * Locale name * @var string * @access public */ var $locale = 'cs'; /** * Language name in English * @var string * @access public */ var $lang = 'Czech'; /** * Native language name * @var string * @access public */ var $lang_native = 'Czech'; /** * The word for the minus sign * @var string * @access private */ var $_minus = 'mínus'; // minus sign /** * The sufixes for exponents (singular and plural) * Names partly based on: * http://cs.wikipedia.org/wiki/P%C5%99edpony_soustavy_SI * the rest was translated from lang.en_GB.php * names verified by "Ustav pro jazyk cesky" only up to Septilion * (they could verify only the lingual matter - not the mathematical one) * @var array * @access private */ var $_exponent = array( 0 => array(''), 3 => array('tisíc','tisíce','tisíc'), 6 => array('milion','miliony','milionù'), 9 => array('miliarda','miliardy','miliard'), 12 => array('bilion','biliony','bilionù'), 15 => array('biliarda','biliardy','biliard'), 18 => array('trilion','triliony','trilionù'), 21 => array('triliarda','triliardy','triliard'), 24 => array('kvadrilion','kvadriliony','kvadrilionù'), 30 => array('kvintilion','kvintiliony','kvintilionù'), 36 => array('sextilion','sextiliony','sextilionù'), 42 => array('septilion','septiliony','septilionù'), 48 => array('oktilion','oktiliony','oktilionù'), 54 => array('nonilion','noniliony','nonilionù'), 60 => array('decilion','deciliony','decilionù'), 66 => array('undecilion','undeciliony','undecilionù'), 72 => array('duodecilion','duodeciliony','duodecilionù'), 78 => array('tredecilion','tredeciliony','tredecilionù'), 84 => array('kvatrodecilion','kvatrodeciliony','kvatrodecilionù'), 90 => array('kvindecilion','kvindeciliony','kvindecilionù'), 96 => array('sexdecilion','sexdeciliony','sexdecilionù'), 102 => array('septendecilion','septendeciliony','septendecilionù'), 108 => array('oktodecilion','oktodeciliony','oktodecilionù'), 114 => array('novemdecilion','novemdeciliony','novemdecilionù'), 120 => array('vigintilion','vigintiliony','vigintilionù'), 192 => array('duotrigintilion','duotrigintiliony','duotrigintilionù'), 600 => array('centilion','centiliony','centilionù') ); /** * The array containing the forms of Czech word for "hundred" * @var array * @access private */ var $_hundreds = array( 0 => 'sto', 'stì', 'sta', 'set' ); /** * The array containing the digits (indexed by the digits themselves). * @var array * @access private */ var $_digits = array( 0 => 'nula', 'jedna', 'dva', 'tøi', 'ètyøi', 'pìt', '¹est', 'sedm', 'osm', 'devìt' ); /** * The word separator * @var string * @access private */ var $_sep = ' '; // }}} // {{{ _toWords() /** * Converts a number to its word representation * in Czech language * * @param integer $num An integer between -infinity and infinity inclusive :) * that need to be converted to words * @param integer $power The power of ten for the rest of the number to the right. * Optional, defaults to 0. * @param integer $powsuffix The power name to be added to the end of the return string. * Used internally. Optional, defaults to ''. * * @return string The corresponding word representation * * @access protected * @author Petr 'PePa' Pavel * @since Numbers_Words 0.16.3 */ function _toWords($num, $power = 0, $powsuffix = '') { $ret = ''; // add a minus sign if (substr($num, 0, 1) == '-') { $ret = $this->_sep . $this->_minus; $num = substr($num, 1); } // strip excessive zero signs and spaces $num = trim($num); $num = preg_replace('/^0+/', '', $num); if (strlen($num) > 3) { $maxp = strlen($num)-1; $curp = $maxp; for ($p = $maxp; $p > 0; --$p) { // power // check for highest power if (isset($this->_exponent[$p])) { // send substr from $curp to $p $snum = substr($num, $maxp - $curp, $curp - $p + 1); $snum = preg_replace('/^0+/', '', $snum); if ($snum !== '') { $cursuffix = $this->_exponent[$power][count($this->_exponent[$power])-1]; if ($powsuffix != '') { $cursuffix .= $this->_sep . $powsuffix; } $ret .= $this->_toWords($snum, $p, $cursuffix); } $curp = $p - 1; continue; } } $num = substr($num, $maxp - $curp, $curp - $p + 1); if ($num == 0) { return $ret; } } elseif ($num == 0 || $num == '') { return $this->_sep . $this->_digits[0]; } $h = $t = $d = 0; switch(strlen($num)) { case 3: $h = (int)substr($num, -3, 1); case 2: $t = (int)substr($num, -2, 1); case 1: $d = (int)substr($num, -1, 1); break; case 0: return; break; } if ($h) { // inflection of the word "hundred" if ($h == 1) { $ret .= $this->_sep . $this->_hundreds[0]; } elseif ($h == 2) { $ret .= $this->_sep . "dvì" . $this->_sep . $this->_hundreds[1]; } elseif ( ($h > 1) && ($h < 5) ) { $ret .= $this->_sep . $this->_digits[$h] . $this->_sep . $this->_hundreds[2]; } else { //if ($h >= 5) $ret .= $this->_sep . $this->_digits[$h] . $this->_sep . $this->_hundreds[3]; } // in English only - add ' and' for [1-9]01..[1-9]99 // (also for 1001..1099, 10001..10099 but it is harder) // for now it is switched off, maybe some language purists // can force me to enable it, or to remove it completely // if (($t + $d) > 0) // $ret .= $this->_sep . 'and'; } // ten, twenty etc. switch ($t) { case 2: case 3: case 4: $ret .= $this->_sep . $this->_digits[$t] . 'cet'; break; case 5: $ret .= $this->_sep . 'padesát'; break; case 6: $ret .= $this->_sep . '¹edesát'; break; case 7: $ret .= $this->_sep . 'sedmdesát'; break; case 8: $ret .= $this->_sep . 'osmdesát'; break; case 9: $ret .= $this->_sep . 'devadesát'; break; case 1: switch ($d) { case 0: $ret .= $this->_sep . 'deset'; break; case 1: $ret .= $this->_sep . 'jedenáct'; break; case 4: $ret .= $this->_sep . 'ètrnáct'; break; case 5: $ret .= $this->_sep . 'patnáct'; break; case 9: $ret .= $this->_sep . 'devatenáct'; break; case 2: case 3: case 6: case 7: case 8: $ret .= $this->_sep . $this->_digits[$d] . 'náct'; break; } break; } if (($t != 1) && ($d > 0) && (($power == 0) || ($num > 1))) { $ret .= $this->_sep . $this->_digits[$d]; } if ($power > 0) { if (isset($this->_exponent[$power])) { $lev = $this->_exponent[$power]; } if (!isset($lev) || !is_array($lev)) { return null; } // inflection of exponental words if ($num == 1) { $idx = 0; } elseif ( (($num > 1) && ($num < 5)) || ((intval("$t$d") > 1) && (intval("$t$d") < 5))) { $idx = 1; } else { $idx = 2; } $ret .= $this->_sep . $lev[$idx]; } if ($powsuffix != '') { $ret .= $this->_sep . $powsuffix; } return $ret; } // }}} } Numbers_Words-0.16.4/Numbers/Words/lang.de.php0000644000076500007650000002163311732225114017624 0ustar igorigor * @license PHP 3.01 http://www.php.net/license/3_01.txt * @version SVN: $Id$ * @link http://pear.php.net/package/Numbers_Words */ /** * * Class for translating numbers into German. * @author Piotr Klaban * @package Numbers_Words */ /** * Include needed files */ require_once "Numbers/Words.php"; /** * Class for translating numbers into German. * * @category Numbers * @package Numbers_Words * @author Piotr Klaban * @license PHP 3.01 http://www.php.net/license/3_01.txt * @link http://pear.php.net/package/Numbers_Words */ class Numbers_Words_de extends Numbers_Words { // {{{ properties /** * Locale name * @var string * @access public */ var $locale = 'de'; /** * Language name in English * @var string * @access public */ var $lang = 'German'; /** * Native language name * @var string * @access public */ var $lang_native = 'Deutsch'; /** * The word for the minus sign * @var string * @access private */ var $_minus = 'Minus'; // minus sign /** * The sufixes for exponents (singular and plural) * Names partly based on: * http://german.about.com/library/blzahlenaud.htm * http://www3.osk.3web.ne.jp/~nagatani/common/zahlwort.htm * @var array * @access private */ var $_exponent = array( 0 => array(''), 3 => array('tausend','tausend'), 6 => array('Million','Millionen'), 9 => array('Milliarde','Milliarden'), 12 => array('Billion','Billionen'), 15 => array('Billiarde','Billiarden'), 18 => array('Trillion','Trillionen'), 21 => array('Trilliarde','Trilliarden'), 24 => array('Quadrillion','Quadrillionen'), 27 => array('Quadrilliarde','Quadrilliarden'), 30 => array('Quintillion','Quintillionen'), 33 => array('Quintilliarde','Quintilliarden'), 36 => array('Sextillion','Sextillionen'), 39 => array('Sextilliarde','Sextilliarden'), 42 => array('Septillion','Septillionen'), 45 => array('Septilliarde','Septilliarden'), 48 => array('Oktillion','Oktillionen'), // oder Octillionen 51 => array('Oktilliarde','Oktilliarden'), 54 => array('Nonillion','Nonillionen'), 57 => array('Nonilliarde','Nonilliarden'), 60 => array('Dezillion','Dezillionen'), 63 => array('Dezilliarde','Dezilliarden'), 120 => array('Vigintillion','Vigintillionen'), 123 => array('Vigintilliarde','Vigintilliarden'), 600 => array('Zentillion','Zentillionen'), // oder Centillion 603 => array('Zentilliarde','Zentilliarden') ); /** * The array containing the digits (indexed by the digits themselves). * @var array * @access private */ var $_digits = array( 0 => 'null', 'ein', 'zwei', 'drei', 'vier', 'fünf', 'sechs', 'sieben', 'acht', 'neun' ); /** * The word separator * @var string * @access private */ var $_sep = ''; /** * The exponent word separator * @var string * @access private */ var $_sep2 = ' '; // }}} // {{{ _toWords() /** * Converts a number to its word representation * in German language. * * @param integer $num An integer between -infinity and infinity inclusive :) * that need to be converted to words * @param integer $power The power of ten for the rest of the number to the right. * Optional, defaults to 0. * @param integer $powsuffix The power name to be added to the end of the return string. * Used internally. Optional, defaults to ''. * * @return string The corresponding word representation * * @access protected * @author Piotr Klaban * @since Numbers_Words 0.16.3 */ function _toWords($num, $power = 0, $powsuffix = '') { $ret = ''; // add a minus sign if (substr($num, 0, 1) == '-') { $ret = $this->_sep . $this->_minus; $num = substr($num, 1); } // strip excessive zero signs and spaces $num = trim($num); $num = preg_replace('/^0+/', '', $num); if (strlen($num) > 3) { $maxp = strlen($num)-1; $curp = $maxp; for ($p = $maxp; $p > 0; --$p) { // power // check for highest power if (isset($this->_exponent[$p])) { // send substr from $curp to $p $snum = substr($num, $maxp - $curp, $curp - $p + 1); $snum = preg_replace('/^0+/', '', $snum); if ($snum !== '') { $cursuffix = $this->_exponent[$power][count($this->_exponent[$power])-1]; if ($powsuffix != '') { $cursuffix .= $this->_sep . $powsuffix; } $ret .= $this->_toWords($snum, $p, $cursuffix); } $curp = $p - 1; continue; } } $num = substr($num, $maxp - $curp, $curp - $p + 1); if ($num == 0) { return $ret; } } elseif ($num == 0 || $num == '') { return $this->_sep . $this->_digits[0]; } $h = $t = $d = 0; switch(strlen($num)) { case 3: $h = (int)substr($num, -3, 1); case 2: $t = (int)substr($num, -2, 1); case 1: $d = (int)substr($num, -1, 1); break; case 0: return; break; } if ($h) { $ret .= $this->_sep . $this->_digits[$h] . $this->_sep . 'hundert'; } if ($t != 1 && $d > 0) { // add digits only in <0>,<1,9> and <21,inf> if ($t > 0) { $ret .= $this->_digits[$d] . 'und'; } else { $ret .= $this->_digits[$d]; if ($d == 1) { if ($power == 0) { $ret .= 's'; // fuer eins } else { if ($power != 3) { // tausend ausnehmen $ret .= 'e'; // fuer eine } } } } } // ten, twenty etc. switch ($t) { case 9: case 8: case 5: $ret .= $this->_sep . $this->_digits[$t] . 'zig'; break; case 7: $ret .= $this->_sep . 'siebzig'; break; case 6: $ret .= $this->_sep . 'sechzig'; break; case 4: $ret .= $this->_sep . 'vierzig'; break; case 3: $ret .= $this->_sep . 'dreißig'; break; case 2: $ret .= $this->_sep . 'zwanzig'; break; case 1: switch ($d) { case 0: $ret .= $this->_sep . 'zehn'; break; case 1: $ret .= $this->_sep . 'elf'; break; case 2: $ret .= $this->_sep . 'zwölf'; break; case 3: case 4: case 5: case 8: case 9: $ret .= $this->_sep . $this->_digits[$d] . 'zehn'; break; case 6: $ret .= $this->_sep . 'sechzehn'; break; case 7: $ret .= $this->_sep . 'siebzehn'; break; } break; } if ($power > 0) { if (isset($this->_exponent[$power])) { $lev = $this->_exponent[$power]; } if (!isset($lev) || !is_array($lev)) { return null; } if ($power == 3) { $ret .= $this->_sep . $lev[0]; } elseif ($d == 1 && ($t+$h) == 0) { $ret .= $this->_sep2 . $lev[0] . $this->_sep2; } else { $ret .= $this->_sep2 . $lev[1] . $this->_sep2; } } if ($powsuffix != '') { $ret .= $this->_sep . $powsuffix; } return $ret; } // }}} } Numbers_Words-0.16.4/Numbers/Words/lang.dk.php0000644000076500007650000003074611732225114017637 0ustar igorigor * @license PHP 3.01 http://www.php.net/license/3_01.txt * @version SVN: $Id$ * @link http://pear.php.net/package/Numbers_Words */ /** * Class for translating numbers into Danish. * * @author Jesper Veggerby * @package Numbers_Words */ /** * Include needed files */ require_once "Numbers/Words.php"; /** * Class for translating numbers into Danish. * * @category Numbers * @package Numbers_Words * @author Jesper Veggerby * @license PHP 3.01 http://www.php.net/license/3_01.txt * @link http://pear.php.net/package/Numbers_Words */ class Numbers_Words_dk extends Numbers_Words { // {{{ properties /** * Locale name * @var string * @access public */ var $locale = 'dk'; /** * Language name in English * @var string * @access public */ var $lang = 'Danish'; /** * Native language name * @var string * @access public */ var $lang_native = 'Dansk'; /** * The word for the minus sign * @var string * @access private */ var $_minus = 'minus'; // minus sign /** * The sufixes for exponents (singular and plural). * From: http://da.wikipedia.org/wiki/Navne_p%E5_store_tal * @var array * @access private */ var $_exponent = array( 0 => array(''), 3 => array('tusind','tusinde'), 6 => array('million','millioner'), 9 => array('milliard','milliarder'), 12 => array('billion','billioner'), 15 => array('billiard','billiarder'), 18 => array('trillion','trillioner'), 21 => array('trilliard','trilliarder'), 24 => array('quadrillion','quadrillioner'), 30 => array('quintillion','quintillioner'), 36 => array('sextillion','sextillioner'), 42 => array('septillion','septillioner'), 48 => array('octillion','octillioner'), 54 => array('nonillion','nonillioner'), 60 => array('decillion','decillioner'), 120 => array('vigintillion','vigintillioner'), 600 => array('centillion','centillioner') ); /** * The array containing the digits (indexed by the digits themselves). * @var array * @access private */ var $_digits = array( 0 => 'nul', 'en', 'to', 'tre', 'fire', 'fem', 'seks', 'syv', 'otte', 'ni' ); /** * The word separator * @var string * @access private */ var $_sep = ' '; /** * The currency names (based on the below links, * informations from central bank websites and on encyclopedias) * * @var array * @link http://da.wikipedia.org/wiki/Valuta * @access private */ var $_currency_names = array( 'AUD' => array(array('australsk dollar', 'australske dollars'), array('cent')), 'CAD' => array(array('canadisk dollar', 'canadisk dollars'), array('cent')), 'CHF' => array(array('schweitzer franc'), array('rappen')), 'CYP' => array(array('cypriotisk pund', 'cypriotiske pund'), array('cent')), 'CZK' => array(array('tjekkisk koruna'), array('halerz')), 'DKK' => array(array('krone', 'kroner'), array('øre')), 'EUR' => array(array('euro'), array('euro-cent')), 'GBP' => array(array('pund'), array('pence')), 'HKD' => array(array('Hong Kong dollar', 'Hong Kong dollars'), array('cent')), 'JPY' => array(array('yen'), array('sen')), 'NOK' => array(array('norsk krone', 'norske kroner'), array('øre')), 'PLN' => array(array('zloty', 'zlotys'), array('grosz')), 'SEK' => array(array('svensk krone', 'svenske kroner'), array('øre')), 'USD' => array(array('dollar', 'dollars'), array('cent')) ); /** * The default currency name * @var string * @access public */ var $def_currency = 'DKK'; // Danish krone // }}} // {{{ _toWords() /** * Converts a number to its word representation * in Danish language * * @param integer $num An integer between -infinity and infinity inclusive :) * that need to be converted to words * @param integer $power The power of ten for the rest of the number to the right. * Optional, defaults to 0. * @param integer $powsuffix The power name to be added to the end of the return string. * Used internally. Optional, defaults to ''. * * @return string The corresponding word representation * * @access protected * @author Jesper Veggerby * @since Numbers_Words 0.16.3 */ function _toWords($num, $power = 0, $powsuffix = '') { $ret = ''; // add a minus sign if (substr($num, 0, 1) == '-') { $ret = $this->_sep . $this->_minus; $num = substr($num, 1); } // strip excessive zero signs and spaces $num = trim($num); $num = preg_replace('/^0+/', '', $num); if (strlen($num) > 3) { $maxp = strlen($num)-1; $curp = $maxp; for ($p = $maxp; $p > 0; --$p) { // power // check for highest power if (isset($this->_exponent[$p])) { // send substr from $curp to $p $snum = substr($num, $maxp - $curp, $curp - $p + 1); $snum = preg_replace('/^0+/', '', $snum); if ($snum !== '') { $cursuffix = $this->_exponent[$power][count($this->_exponent[$power])-1]; if ($powsuffix != '') { $cursuffix .= $this->_sep . $powsuffix; } $ret .= $this->_toWords($snum, $p, $cursuffix); } $curp = $p - 1; continue; } } $num = substr($num, $maxp - $curp, $curp - $p + 1); if ($num == 0) { return $ret; } } elseif ($num == 0 || $num == '') { return $this->_sep . $this->_digits[0]; } $h = $t = $d = 0; switch(strlen($num)) { case 3: $h = (int)substr($num, -3, 1); case 2: $t = (int)substr($num, -2, 1); case 1: $d = (int)substr($num, -1, 1); break; case 0: return; break; } if ($h) { if ($h == 1) { $ret .= $this->_sep . 'et' . $this->_sep . 'hundrede'; } else { $ret .= $this->_sep . $this->_digits[$h] . $this->_sep . 'hundrede'; } //if (($t + $d) > 0) // $ret .= $this->_sep . 'og'; } elseif ((isset($maxp)) && ($maxp > 3)) { // add 'og' in the case where there are preceding thousands but not hundreds or tens, // so fx. 80001 becomes 'firs tusinde og en' instead of 'firs tusinde en' $ret .= $this->_sep . 'og'; } if ($t != 1 && $d > 0) { $ret .= $this->_sep . (($d == 1 & $power == 3 && $t == 0 && $h == 0) ? "et" : $this->_digits[$d]) . ($t > 1 ? $this->_sep . "og" : ""); } // ten, twenty etc. switch ($t) { case 9: $ret .= $this->_sep . 'halvfems'; break; case 8: $ret .= $this->_sep . 'firs'; break; case 7: $ret .= $this->_sep . 'halvfjerds'; break; case 6: $ret .= $this->_sep . 'tres'; break; case 5: $ret .= $this->_sep . 'halvtreds'; break; case 4: $ret .= $this->_sep . 'fyrre'; break; case 3: $ret .= $this->_sep . 'tredive'; break; case 2: $ret .= $this->_sep . 'tyve'; break; case 1: switch ($d) { case 0: $ret .= $this->_sep . 'ti'; break; case 1: $ret .= $this->_sep . 'elleve'; break; case 2: $ret .= $this->_sep . 'tolv'; break; case 3: $ret .= $this->_sep . 'tretten'; break; case 4: $ret .= $this->_sep . 'fjorten'; break; case 5: $ret .= $this->_sep . 'femten'; break; case 6: $ret .= $this->_sep . 'seksten'; break; case 7: $ret .= $this->_sep . 'sytten'; break; case 8: $ret .= $this->_sep . 'atten'; break; case 9: $ret .= $this->_sep . 'nitten'; break; } break; } if ($power > 0) { if (isset($this->_exponent[$power])) { $lev = $this->_exponent[$power]; } if (!isset($lev) || !is_array($lev)) { return null; } if ($d == 1 && ($t+$h) == 0) { $ret .= $this->_sep . $lev[0]; } else { $ret .= $this->_sep . $lev[1]; } } if ($powsuffix != '') { $ret .= $this->_sep . $powsuffix; } return $ret; } // }}} // {{{ toCurrencyWords() /** * Converts a currency value to its word representation * (with monetary units) in danish language * * @param integer $int_curr An international currency symbol * as defined by the ISO 4217 standard (three characters) * @param integer $decimal A money total amount without fraction part (e.g. amount of dollars) * @param integer $fraction Fractional part of the money amount (e.g. amount of cents) * Optional. Defaults to false. * @param integer $convert_fraction Convert fraction to words (left as numeric if set to false). * Optional. Defaults to true. * * @return string The corresponding word representation for the currency * * @access public * @author Jesper Veggerby * @since Numbers_Words 0.4 */ function toCurrencyWords($int_curr, $decimal, $fraction = false, $convert_fraction = true) { $int_curr = strtoupper($int_curr); if (!isset($this->_currency_names[$int_curr])) { $int_curr = $this->def_currency; } $curr_names = $this->_currency_names[$int_curr]; if (($decimal != "") and ($decimal != 0)) { $ret = trim($this->_toWords($decimal)); $lev = ($decimal == 1) ? 0 : 1; if ($lev > 0) { if (count($curr_names[0]) > 1) { $ret .= $this->_sep . $curr_names[0][$lev]; } else { $ret .= $this->_sep . $curr_names[0][0]; } } else { $ret .= $this->_sep . $curr_names[0][0]; } if (($fraction !== false) and ($fraction != 0)) { $ret .= $this->_sep . "og"; } } if (($fraction !== false) and ($fraction != 0)) { if ($convert_fraction) { $ret .= $this->_sep . trim($this->_toWords($fraction)); } else { $ret .= $this->_sep . $fraction; } $lev = ($fraction == 1) ? 0 : 1; if ($lev > 0) { if (count($curr_names[1]) > 1) { $ret .= $this->_sep . $curr_names[1][$lev]; } else { $ret .= $this->_sep . $curr_names[1][0]; } } else { $ret .= $this->_sep . $curr_names[1][0]; } } return $ret; } // }}} } Numbers_Words-0.16.4/Numbers/Words/lang.en_100.php0000644000076500007650000002051711732225114020216 0ustar igorigor * @license PHP 3.01 http://www.php.net/license/3_01.txt * @version SVN: $Id$ * @link http://pear.php.net/package/Numbers_Words */ /** * Class for translating numbers into Donald Knuth system, in English language. * * @author Piotr Klaban * @package Numbers_Words */ /** * Include needed files */ require_once "Numbers/Words.php"; /** * Class for translating numbers into Donald Knuth system, in English language. * * @category Numbers * @package Numbers_Words * @author Piotr Klaban * @license PHP 3.01 http://www.php.net/license/3_01.txt * @link http://pear.php.net/package/Numbers_Words */ class Numbers_Words_en_100 extends Numbers_Words { // {{{ properties /** * Locale name * @var string * @access public */ var $locale = 'en_100'; /** * Language name in English * @var string * @access public */ var $lang = 'English (Donald Knuth system)'; /** * Native language name * @var string * @access public */ var $lang_native = 'English (Donald Knuth system)'; /** * The word for the minus sign * @var string * @access private */ var $_minus = 'minus'; // minus sign /** * The sufixes for exponents (singular and plural) * Names based on: * http://home.earthlink.net/~mrob/pub/math/largenum.html * Donald Knuth system (power of 2) * @var array * @access private */ var $_exponent = array( 0 => array(''), 2 => array('hundred'), 4 => array('myriad'), 8 => array('myllion'), 16 => array('byllion'), 32 => array('tryllion'), 64 => array('quadryllion'), 128 => array('quintyllion'), 256 => array('sextyllion'), 512 => array('septyllion'), 1024 => array('octyllion'), 2048 => array('nonyllion'), 4096 => array('decyllion'), 8192 => array('undecyllion'), 16384 => array('duodecyllion'), 32768 => array('tredecyllion'), 65536 => array('quattuordecyllion'), 131072 => array('quindecyllion'), 262144 => array('sexdecyllion'), 524288 => array('septendecyllion'), 1048576 => array('octodecyllion'), 2097152 => array('novemdecyllion'), 4194304 => array('vigintyllion') ); /** * The array containing the digits (indexed by the digits themselves). * @var array * @access private */ var $_digits = array( 0 => 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine' ); /** * The word separator * @var string * @access private */ var $_sep = ' '; // }}} // {{{ _toWords() /** * Converts a number to its word representation * in Donald Knuth system, in English language. * * @param integer $num An integer between -infinity and infinity inclusive :) * that need to be converted to words * @param integer $power The power of ten for the rest of the number to the right. * Optional, defaults to 0. * @param integer $powsuffix The power name to be added to the end of the return string. * Used internally. Optional, defaults to ''. * * @return string The corresponding word representation * * @access protected * @author Piotr Klaban * @since Numbers_Words 0.16.3 */ function _toWords($num, $power = 0, $powsuffix = '') { $ret = ''; // add a minus sign if (substr($num, 0, 1) == '-') { $ret = $this->_sep . $this->_minus; $num = substr($num, 1); } // strip excessive zero signs and spaces $num = trim($num); $num = preg_replace('/^0+/', '', $num); if (strlen($num) > 3) { $maxp = strlen($num)-1; $curp = $maxp; for ($p = $maxp; $p > 0; --$p) { // power // check for highest power if (isset($this->_exponent[$p])) { // send substr from $curp to $p $snum = substr($num, $maxp - $curp, $curp - $p + 1); $snum = preg_replace('/^0+/', '', $snum); if ($snum !== '') { $cursuffix = $this->_exponent[$power][count($this->_exponent[$power])-1]; if ($powsuffix != '') { $cursuffix .= $this->_sep . $powsuffix; } $ret .= $this->_toWords($snum, $p, $cursuffix); } $curp = $p - 1; continue; } } $num = substr($num, $maxp - $curp, $curp - $p + 1); if ($num == 0) { return $ret; } } elseif ($num == 0 || $num == '') { return $this->_sep . $this->_digits[0]; } $h = $t = $d = 0; switch(strlen($num)) { case 3: $h = (int)substr($num, -3, 1); case 2: $t = (int)substr($num, -2, 1); case 1: $d = (int)substr($num, -1, 1); break; case 0: return; break; } if ($h) { $ret .= $this->_sep . $this->_digits[$h] . $this->_sep . 'hundred'; // in English only - add ' and' for [1-9]01..[1-9]99 // (also for 1001..1099, 10001..10099 but it is harder) // for now it is switched off, maybe some language purists // can force me to enable it, or to remove it completely // if (($t + $d) > 0) // $ret .= $this->_sep . 'and'; } // ten, twenty etc. switch ($t) { case 9: case 7: case 6: $ret .= $this->_sep . $this->_digits[$t] . 'ty'; break; case 8: $ret .= $this->_sep . 'eighty'; break; case 5: $ret .= $this->_sep . 'fifty'; break; case 4: $ret .= $this->_sep . 'forty'; break; case 3: $ret .= $this->_sep . 'thirty'; break; case 2: $ret .= $this->_sep . 'twenty'; break; case 1: switch ($d) { case 0: $ret .= $this->_sep . 'ten'; break; case 1: $ret .= $this->_sep . 'eleven'; break; case 2: $ret .= $this->_sep . 'twelve'; break; case 3: $ret .= $this->_sep . 'thirteen'; break; case 4: case 6: case 7: case 9: $ret .= $this->_sep . $this->_digits[$d] . 'teen'; break; case 5: $ret .= $this->_sep . 'fifteen'; break; case 8: $ret .= $this->_sep . 'eighteen'; break; } break; } if ($t != 1 && $d > 0) { // add digits only in <0>,<1,9> and <21,inf> // add minus sign between [2-9] and digit if ($t > 1) { $ret .= '-' . $this->_digits[$d]; } else { $ret .= $this->_sep . $this->_digits[$d]; } } if ($power > 0) { if (isset($this->_exponent[$power])) { $lev = $this->_exponent[$power]; } if (!isset($lev) || !is_array($lev)) { return null; } $ret .= $this->_sep . $lev[0]; } if ($powsuffix != '') { $ret .= $this->_sep . $powsuffix; } return $ret; } // }}} } Numbers_Words-0.16.4/Numbers/Words/lang.en_GB.php0000644000076500007650000003244311732225114020207 0ustar igorigor * @license PHP 3.01 http://www.php.net/license/3_01.txt * @version SVN: $Id$ * @link http://pear.php.net/package/Numbers_Words */ /** * Class for translating numbers into British English. * * @author Piotr Klaban * @package Numbers_Words */ /** * Include needed files */ require_once "Numbers/Words.php"; /** * Class for translating numbers into British English. * * @category Numbers * @package Numbers_Words * @author Piotr Klaban * @license PHP 3.01 http://www.php.net/license/3_01.txt * @link http://pear.php.net/package/Numbers_Words */ class Numbers_Words_en_GB extends Numbers_Words { // {{{ properties /** * Locale name * @var string * @access public */ var $locale = 'en_GB'; /** * Language name in English * @var string * @access public */ var $lang = 'British English'; /** * Native language name * @var string * @access public */ var $lang_native = 'British English'; /** * The word for the minus sign * @var string * @access private */ var $_minus = 'minus'; // minus sign /** * The sufixes for exponents (singular and plural) * Names partly based on: * http://www.users.dircon.co.uk/~shaunf/shaun/numbers/millions.htm * @var array * @access private */ var $_exponent = array( 0 => array(''), 3 => array('thousand'), 6 => array('million'), 12 => array('billion'), 18 => array('trillion'), 24 => array('quadrillion'), 30 => array('quintillion'), 36 => array('sextillion'), 42 => array('septillion'), 48 => array('octillion'), 54 => array('nonillion'), 60 => array('decillion'), 66 => array('undecillion'), 72 => array('duodecillion'), 78 => array('tredecillion'), 84 => array('quattuordecillion'), 90 => array('quindecillion'), 96 => array('sexdecillion'), 102 => array('septendecillion'), 108 => array('octodecillion'), 114 => array('novemdecillion'), 120 => array('vigintillion'), 192 => array('duotrigintillion'), 600 => array('centillion') ); /** * The array containing the digits (indexed by the digits themselves). * @var array * @access private */ var $_digits = array( 0 => 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine' ); /** * The word separator * @var string * @access private */ var $_sep = ' '; /** * The currency names (based on the below links, * informations from central bank websites and on encyclopedias) * * @var array * @link http://30-03-67.dreamstation.com/currency_alfa.htm World Currency Information * @link http://www.jhall.demon.co.uk/currency/by_abbrev.html World currencies * @link http://www.shoestring.co.kr/world/p.visa/change.htm Currency names in English * @access private */ var $_currency_names = array( 'ALL' => array(array('lek'), array('qindarka')), 'AUD' => array(array('Australian dollar'), array('cent')), 'BAM' => array(array('convertible marka'), array('fenig')), 'BGN' => array(array('lev'), array('stotinka')), 'BRL' => array(array('real'), array('centavos')), 'BYR' => array(array('Belarussian rouble'), array('kopiejka')), 'CAD' => array(array('Canadian dollar'), array('cent')), 'CHF' => array(array('Swiss franc'), array('rapp')), 'CYP' => array(array('Cypriot pound'), array('cent')), 'CZK' => array(array('Czech koruna'), array('halerz')), 'DKK' => array(array('Danish krone'), array('ore')), 'EEK' => array(array('kroon'), array('senti')), 'EUR' => array(array('euro'), array('euro-cent')), 'GBP' => array(array('pound', 'pounds'), array('pence', 'pence')), 'HKD' => array(array('Hong Kong dollar'), array('cent')), 'HRK' => array(array('Croatian kuna'), array('lipa')), 'HUF' => array(array('forint'), array('filler')), 'ILS' => array(array('new sheqel','new sheqels'), array('agora','agorot')), 'ISK' => array(array('Icelandic króna'), array('aurar')), 'JPY' => array(array('yen'), array('sen')), 'LTL' => array(array('litas'), array('cent')), 'LVL' => array(array('lat'), array('sentim')), 'MKD' => array(array('Macedonian dinar'), array('deni')), 'MTL' => array(array('Maltese lira'), array('centym')), 'NOK' => array(array('Norwegian krone'), array('oere')), 'PLN' => array(array('zloty', 'zlotys'), array('grosz')), 'ROL' => array(array('Romanian leu'), array('bani')), 'RUB' => array(array('Russian Federation rouble'), array('kopiejka')), 'SEK' => array(array('Swedish krona'), array('oere')), 'SIT' => array(array('Tolar'), array('stotinia')), 'SKK' => array(array('Slovak koruna'), array()), 'TRL' => array(array('lira'), array('kuruþ')), 'UAH' => array(array('hryvna'), array('cent')), 'USD' => array(array('dollar'), array('cent')), 'YUM' => array(array('dinars'), array('para')), 'ZAR' => array(array('rand'), array('cent')) ); /** * The default currency name * @var string * @access public */ var $def_currency = 'GBP'; // English pound // }}} // {{{ _toWords() /** * Converts a number to its word representation * in British English language * * @param integer $num An integer between -infinity and infinity inclusive :) * that need to be converted to words * @param integer $power The power of ten for the rest of the number to the right. * Optional, defaults to 0. * @param integer $powsuffix The power name to be added to the end of the return string. * Used internally. Optional, defaults to ''. * * @return string The corresponding word representation * * @access protected * @author Piotr Klaban * @since Numbers_Words 0.16.3 */ function _toWords($num, $power = 0, $powsuffix = '') { $ret = ''; // add a minus sign if (substr($num, 0, 1) == '-') { $ret = $this->_sep . $this->_minus; $num = substr($num, 1); } // strip excessive zero signs and spaces $num = trim($num); $num = preg_replace('/^0+/', '', $num); if (strlen($num) > 3) { $maxp = strlen($num)-1; $curp = $maxp; for ($p = $maxp; $p > 0; --$p) { // power // check for highest power if (isset($this->_exponent[$p])) { // send substr from $curp to $p $snum = substr($num, $maxp - $curp, $curp - $p + 1); $snum = preg_replace('/^0+/', '', $snum); if ($snum !== '') { $cursuffix = $this->_exponent[$power][count($this->_exponent[$power])-1]; if ($powsuffix != '') { $cursuffix .= $this->_sep . $powsuffix; } $ret .= $this->_toWords($snum, $p, $cursuffix); } $curp = $p - 1; continue; } } $num = substr($num, $maxp - $curp, $curp - $p + 1); if ($num == 0) { return $ret; } } elseif ($num == 0 || $num == '') { return $this->_sep . $this->_digits[0]; } $h = $t = $d = 0; switch(strlen($num)) { case 3: $h = (int)substr($num, -3, 1); case 2: $t = (int)substr($num, -2, 1); case 1: $d = (int)substr($num, -1, 1); break; case 0: return; break; } if ($h) { $ret .= $this->_sep . $this->_digits[$h] . $this->_sep . 'hundred'; // in English only - add ' and' for [1-9]01..[1-9]99 // (also for 1001..1099, 10001..10099 but it is harder) // for now it is switched off, maybe some language purists // can force me to enable it, or to remove it completely // if (($t + $d) > 0) // $ret .= $this->_sep . 'and'; } // ten, twenty etc. switch ($t) { case 9: case 7: case 6: $ret .= $this->_sep . $this->_digits[$t] . 'ty'; break; case 8: $ret .= $this->_sep . 'eighty'; break; case 5: $ret .= $this->_sep . 'fifty'; break; case 4: $ret .= $this->_sep . 'forty'; break; case 3: $ret .= $this->_sep . 'thirty'; break; case 2: $ret .= $this->_sep . 'twenty'; break; case 1: switch ($d) { case 0: $ret .= $this->_sep . 'ten'; break; case 1: $ret .= $this->_sep . 'eleven'; break; case 2: $ret .= $this->_sep . 'twelve'; break; case 3: $ret .= $this->_sep . 'thirteen'; break; case 4: case 6: case 7: case 9: $ret .= $this->_sep . $this->_digits[$d] . 'teen'; break; case 5: $ret .= $this->_sep . 'fifteen'; break; case 8: $ret .= $this->_sep . 'eighteen'; break; } break; } if ($t != 1 && $d > 0) { // add digits only in <0>,<1,9> and <21,inf> // add minus sign between [2-9] and digit if ($t > 1) { $ret .= '-' . $this->_digits[$d]; } else { $ret .= $this->_sep . $this->_digits[$d]; } } if ($power > 0) { if (isset($this->_exponent[$power])) { $lev = $this->_exponent[$power]; } if (!isset($lev) || !is_array($lev)) { return null; } $ret .= $this->_sep . $lev[0]; } if ($powsuffix != '') { $ret .= $this->_sep . $powsuffix; } return $ret; } // }}} // {{{ toCurrencyWords() /** * Converts a currency value to its word representation * (with monetary units) in English language * * @param integer $int_curr An international currency symbol * as defined by the ISO 4217 standard (three characters) * @param integer $decimal A money total amount without fraction part (e.g. amount of dollars) * @param integer $fraction Fractional part of the money amount (e.g. amount of cents) * Optional. Defaults to false. * @param integer $convert_fraction Convert fraction to words (left as numeric if set to false). * Optional. Defaults to true. * * @return string The corresponding word representation for the currency * * @access public * @author Piotr Klaban * @since Numbers_Words 0.13.1 */ function toCurrencyWords($int_curr, $decimal, $fraction = false, $convert_fraction = true) { $int_curr = strtoupper($int_curr); if (!isset($this->_currency_names[$int_curr])) { $int_curr = $this->def_currency; } $curr_names = $this->_currency_names[$int_curr]; $ret = trim($this->_toWords($decimal)); $lev = ($decimal == 1) ? 0 : 1; if ($lev > 0) { if (count($curr_names[0]) > 1) { $ret .= $this->_sep . $curr_names[0][$lev]; } else { $ret .= $this->_sep . $curr_names[0][0] . 's'; } } else { $ret .= $this->_sep . $curr_names[0][0]; } if ($fraction !== false) { if ($convert_fraction) { $ret .= $this->_sep . trim($this->_toWords($fraction)); } else { $ret .= $this->_sep . $fraction; } $lev = ($fraction == 1) ? 0 : 1; if ($lev > 0) { if (count($curr_names[1]) > 1) { $ret .= $this->_sep . $curr_names[1][$lev]; } else { $ret .= $this->_sep . $curr_names[1][0] . 's'; } } else { $ret .= $this->_sep . $curr_names[1][0]; } } return $ret; } // }}} } Numbers_Words-0.16.4/Numbers/Words/lang.en_US.php0000644000076500007650000004220211732225114020240 0ustar igorigor * @license PHP 3.01 http://www.php.net/license/3_01.txt * @version SVN: $Id$ * @link http://pear.php.net/package/Numbers_Words */ /** * Class for translating numbers into American English. * * @author Piotr Klaban * @package Numbers_Words */ /** * Include needed files */ require_once "Numbers/Words.php"; /** * Class for translating numbers into American English. * * @category Numbers * @package Numbers_Words * @author Piotr Klaban * @license PHP 3.01 http://www.php.net/license/3_01.txt * @link http://pear.php.net/package/Numbers_Words */ class Numbers_Words_en_US extends Numbers_Words { // {{{ properties /** * Locale name * @var string * @access public */ var $locale = 'en_US'; /** * Language name in English * @var string * @access public */ var $lang = 'American English'; /** * Native language name * @var string * @access public */ var $lang_native = 'American English'; /** * The word for the minus sign * @var string * @access private */ var $_minus = 'minus'; // minus sign /** * The sufixes for exponents (singular and plural) * Names partly based on: * http://home.earthlink.net/~mrob/pub/math/largenum.html * http://mathforum.org/dr.math/faq/faq.large.numbers.html * http://www.mazes.com/AmericanNumberingSystem.html * @var array * @access private */ var $_exponent = array( 0 => array(''), 3 => array('thousand'), 6 => array('million'), 9 => array('billion'), 12 => array('trillion'), 15 => array('quadrillion'), 18 => array('quintillion'), 21 => array('sextillion'), 24 => array('septillion'), 27 => array('octillion'), 30 => array('nonillion'), 33 => array('decillion'), 36 => array('undecillion'), 39 => array('duodecillion'), 42 => array('tredecillion'), 45 => array('quattuordecillion'), 48 => array('quindecillion'), 51 => array('sexdecillion'), 54 => array('septendecillion'), 57 => array('octodecillion'), 60 => array('novemdecillion'), 63 => array('vigintillion'), 66 => array('unvigintillion'), 69 => array('duovigintillion'), 72 => array('trevigintillion'), 75 => array('quattuorvigintillion'), 78 => array('quinvigintillion'), 81 => array('sexvigintillion'), 84 => array('septenvigintillion'), 87 => array('octovigintillion'), 90 => array('novemvigintillion'), 93 => array('trigintillion'), 96 => array('untrigintillion'), 99 => array('duotrigintillion'), // 100 => array('googol') - not latin name // 10^googol = 1 googolplex 102 => array('trestrigintillion'), 105 => array('quattuortrigintillion'), 108 => array('quintrigintillion'), 111 => array('sextrigintillion'), 114 => array('septentrigintillion'), 117 => array('octotrigintillion'), 120 => array('novemtrigintillion'), 123 => array('quadragintillion'), 126 => array('unquadragintillion'), 129 => array('duoquadragintillion'), 132 => array('trequadragintillion'), 135 => array('quattuorquadragintillion'), 138 => array('quinquadragintillion'), 141 => array('sexquadragintillion'), 144 => array('septenquadragintillion'), 147 => array('octoquadragintillion'), 150 => array('novemquadragintillion'), 153 => array('quinquagintillion'), 156 => array('unquinquagintillion'), 159 => array('duoquinquagintillion'), 162 => array('trequinquagintillion'), 165 => array('quattuorquinquagintillion'), 168 => array('quinquinquagintillion'), 171 => array('sexquinquagintillion'), 174 => array('septenquinquagintillion'), 177 => array('octoquinquagintillion'), 180 => array('novemquinquagintillion'), 183 => array('sexagintillion'), 186 => array('unsexagintillion'), 189 => array('duosexagintillion'), 192 => array('tresexagintillion'), 195 => array('quattuorsexagintillion'), 198 => array('quinsexagintillion'), 201 => array('sexsexagintillion'), 204 => array('septensexagintillion'), 207 => array('octosexagintillion'), 210 => array('novemsexagintillion'), 213 => array('septuagintillion'), 216 => array('unseptuagintillion'), 219 => array('duoseptuagintillion'), 222 => array('treseptuagintillion'), 225 => array('quattuorseptuagintillion'), 228 => array('quinseptuagintillion'), 231 => array('sexseptuagintillion'), 234 => array('septenseptuagintillion'), 237 => array('octoseptuagintillion'), 240 => array('novemseptuagintillion'), 243 => array('octogintillion'), 246 => array('unoctogintillion'), 249 => array('duooctogintillion'), 252 => array('treoctogintillion'), 255 => array('quattuoroctogintillion'), 258 => array('quinoctogintillion'), 261 => array('sexoctogintillion'), 264 => array('septoctogintillion'), 267 => array('octooctogintillion'), 270 => array('novemoctogintillion'), 273 => array('nonagintillion'), 276 => array('unnonagintillion'), 279 => array('duononagintillion'), 282 => array('trenonagintillion'), 285 => array('quattuornonagintillion'), 288 => array('quinnonagintillion'), 291 => array('sexnonagintillion'), 294 => array('septennonagintillion'), 297 => array('octononagintillion'), 300 => array('novemnonagintillion'), 303 => array('centillion'), 309 => array('duocentillion'), 312 => array('trecentillion'), 366 => array('primo-vigesimo-centillion'), 402 => array('trestrigintacentillion'), 603 => array('ducentillion'), 624 => array('septenducentillion'), // bug on a earthlink page: 903 => array('trecentillion'), 2421 => array('sexoctingentillion'), 3003 => array('millillion'), 3000003 => array('milli-millillion') ); /** * The array containing the digits (indexed by the digits themselves). * @var array * @access private */ var $_digits = array( 0 => 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine' ); /** * The word separator * @var string * @access private */ var $_sep = ' '; /** * The currency names (based on the below links, * informations from central bank websites and on encyclopedias) * * @var array * @link http://30-03-67.dreamstation.com/currency_alfa.htm World Currency Information * @link http://www.jhall.demon.co.uk/currency/by_abbrev.html World currencies * @link http://www.shoestring.co.kr/world/p.visa/change.htm Currency names in English * @access private */ var $_currency_names = array( 'ALL' => array(array('lek'), array('qindarka')), 'AUD' => array(array('Australian dollar'), array('cent')), 'BAM' => array(array('convertible marka'), array('fenig')), 'BGN' => array(array('lev'), array('stotinka')), 'BRL' => array(array('real'), array('centavos')), 'BYR' => array(array('Belarussian rouble'), array('kopiejka')), 'CAD' => array(array('Canadian dollar'), array('cent')), 'CHF' => array(array('Swiss franc'), array('rapp')), 'CYP' => array(array('Cypriot pound'), array('cent')), 'CZK' => array(array('Czech koruna'), array('halerz')), 'DKK' => array(array('Danish krone'), array('ore')), 'EEK' => array(array('kroon'), array('senti')), 'EUR' => array(array('euro'), array('euro-cent')), 'GBP' => array(array('pound', 'pounds'), array('pence', 'pence')), 'HKD' => array(array('Hong Kong dollar'), array('cent')), 'HRK' => array(array('Croatian kuna'), array('lipa')), 'HUF' => array(array('forint'), array('filler')), 'ILS' => array(array('new sheqel','new sheqels'), array('agora','agorot')), 'ISK' => array(array('Icelandic króna'), array('aurar')), 'JPY' => array(array('yen'), array('sen')), 'LTL' => array(array('litas'), array('cent')), 'LVL' => array(array('lat'), array('sentim')), 'MKD' => array(array('Macedonian dinar'), array('deni')), 'MTL' => array(array('Maltese lira'), array('centym')), 'NOK' => array(array('Norwegian krone'), array('oere')), 'PLN' => array(array('zloty', 'zlotys'), array('grosz')), 'ROL' => array(array('Romanian leu'), array('bani')), 'RUB' => array(array('Russian Federation rouble'), array('kopiejka')), 'SEK' => array(array('Swedish krona'), array('oere')), 'SIT' => array(array('Tolar'), array('stotinia')), 'SKK' => array(array('Slovak koruna'), array()), 'TRL' => array(array('lira'), array('kuruþ')), 'UAH' => array(array('hryvna'), array('cent')), 'USD' => array(array('dollar'), array('cent')), 'YUM' => array(array('dinars'), array('para')), 'ZAR' => array(array('rand'), array('cent')) ); /** * The default currency name * @var string * @access public */ var $def_currency = 'USD'; // American dollar // }}} // {{{ _toWords() /** * Converts a number to its word representation * in American English language * * @param integer $num An integer between -infinity and infinity inclusive :) * that need to be converted to words * @param integer $power The power of ten for the rest of the number to the right. * Optional, defaults to 0. * @param integer $powsuffix The power name to be added to the end of the return string. * Used internally. Optional, defaults to ''. * * @return string The corresponding word representation * * @access protected * @author Piotr Klaban * @since Numbers_Words 0.16.3 */ function _toWords($num, $power = 0, $powsuffix = '') { $ret = ''; // add a minus sign if (substr($num, 0, 1) == '-') { $ret = $this->_sep . $this->_minus; $num = substr($num, 1); } // strip excessive zero signs and spaces $num = trim($num); $num = preg_replace('/^0+/', '', $num); if (strlen($num) > 3) { $maxp = strlen($num)-1; $curp = $maxp; for ($p = $maxp; $p > 0; --$p) { // power // check for highest power if (isset($this->_exponent[$p])) { // send substr from $curp to $p $snum = substr($num, $maxp - $curp, $curp - $p + 1); $snum = preg_replace('/^0+/', '', $snum); if ($snum !== '') { $cursuffix = $this->_exponent[$power][count($this->_exponent[$power])-1]; if ($powsuffix != '') { $cursuffix .= $this->_sep . $powsuffix; } $ret .= $this->_toWords($snum, $p, $cursuffix); } $curp = $p - 1; continue; } } $num = substr($num, $maxp - $curp, $curp - $p + 1); if ($num == 0) { return $ret; } } elseif ($num == 0 || $num == '') { return $this->_sep . $this->_digits[0]; } $h = $t = $d = 0; switch(strlen($num)) { case 3: $h = (int)substr($num, -3, 1); case 2: $t = (int)substr($num, -2, 1); case 1: $d = (int)substr($num, -1, 1); break; case 0: return; break; } if ($h) { $ret .= $this->_sep . $this->_digits[$h] . $this->_sep . 'hundred'; // in English only - add ' and' for [1-9]01..[1-9]99 // (also for 1001..1099, 10001..10099 but it is harder) // for now it is switched off, maybe some language purists // can force me to enable it, or to remove it completely // if (($t + $d) > 0) // $ret .= $this->_sep . 'and'; } // ten, twenty etc. switch ($t) { case 9: case 7: case 6: $ret .= $this->_sep . $this->_digits[$t] . 'ty'; break; case 8: $ret .= $this->_sep . 'eighty'; break; case 5: $ret .= $this->_sep . 'fifty'; break; case 4: $ret .= $this->_sep . 'forty'; break; case 3: $ret .= $this->_sep . 'thirty'; break; case 2: $ret .= $this->_sep . 'twenty'; break; case 1: switch ($d) { case 0: $ret .= $this->_sep . 'ten'; break; case 1: $ret .= $this->_sep . 'eleven'; break; case 2: $ret .= $this->_sep . 'twelve'; break; case 3: $ret .= $this->_sep . 'thirteen'; break; case 4: case 6: case 7: case 9: $ret .= $this->_sep . $this->_digits[$d] . 'teen'; break; case 5: $ret .= $this->_sep . 'fifteen'; break; case 8: $ret .= $this->_sep . 'eighteen'; break; } break; } if ($t != 1 && $d > 0) { // add digits only in <0>,<1,9> and <21,inf> // add minus sign between [2-9] and digit if ($t > 1) { $ret .= '-' . $this->_digits[$d]; } else { $ret .= $this->_sep . $this->_digits[$d]; } } if ($power > 0) { if (isset($this->_exponent[$power])) { $lev = $this->_exponent[$power]; } if (!isset($lev) || !is_array($lev)) { return null; } $ret .= $this->_sep . $lev[0]; } if ($powsuffix != '') { $ret .= $this->_sep . $powsuffix; } return $ret; } // }}} // {{{ toCurrencyWords() /** * Converts a currency value to its word representation * (with monetary units) in English language * * @param integer $int_curr An international currency symbol * as defined by the ISO 4217 standard (three characters) * @param integer $decimal A money total amount without fraction part (e.g. amount of dollars) * @param integer $fraction Fractional part of the money amount (e.g. amount of cents) * Optional. Defaults to false. * @param integer $convert_fraction Convert fraction to words (left as numeric if set to false). * Optional. Defaults to true. * * @return string The corresponding word representation for the currency * * @access public * @author Piotr Klaban * @since Numbers_Words 0.4 */ function toCurrencyWords($int_curr, $decimal, $fraction = false, $convert_fraction = true) { $int_curr = strtoupper($int_curr); if (!isset($this->_currency_names[$int_curr])) { $int_curr = $this->def_currency; } $curr_names = $this->_currency_names[$int_curr]; $ret = trim($this->_toWords($decimal)); $lev = ($decimal == 1) ? 0 : 1; if ($lev > 0) { if (count($curr_names[0]) > 1) { $ret .= $this->_sep . $curr_names[0][$lev]; } else { $ret .= $this->_sep . $curr_names[0][0] . 's'; } } else { $ret .= $this->_sep . $curr_names[0][0]; } if ($fraction !== false) { if ($convert_fraction) { $ret .= $this->_sep . trim($this->_toWords($fraction)); } else { $ret .= $this->_sep . $fraction; } $lev = ($fraction == 1) ? 0 : 1; if ($lev > 0) { if (count($curr_names[1]) > 1) { $ret .= $this->_sep . $curr_names[1][$lev]; } else { $ret .= $this->_sep . $curr_names[1][0] . 's'; } } else { $ret .= $this->_sep . $curr_names[1][0]; } } return $ret; } // }}} } Numbers_Words-0.16.4/Numbers/Words/lang.es.php0000644000076500007650000002146011732225114017641 0ustar igorigor array('',''), 3 => array('mil','mil'), 6 => array('millón','millones'), 12 => array('billón','billones'), 18 => array('trilón','trillones'), 24 => array('cuatrillón','cuatrillones'), 30 => array('quintillón','quintillones'), 36 => array('sextillón','sextillones'), 42 => array('septillón','septillones'), 48 => array('octallón','octallones'), 54 => array('nonallón','nonallones'), 60 => array('decallón','decallones'), ); /** * The array containing the digits (indexed by the digits themselves). * @var array * @access private */ var $_digits = array( 0 => 'cero', 'uno', 'dos', 'tres', 'cuatro', 'cinco', 'seis', 'siete', 'ocho', 'nueve' ); /** * The word separator * @var string * @access private */ var $_sep = ' '; // }}} // {{{ _toWords() /** * Converts a number to its word representation * in Spanish (Castellano). * * @param integer $num An integer between -infinity and infinity inclusive :) * that should be converted to a words representation * @param integer $power The power of ten for the rest of the number to the right. * For example toWords(12,3) should give "doce mil". * Optional, defaults to 0. * * @return string The corresponding word representation * * @access protected * @author Xavier Noguer * @since Numbers_Words 0.16.3 */ function _toWords($num, $power = 0) { // The return string; $ret = ''; // add a the word for the minus sign if necessary if (substr($num, 0, 1) == '-') { $ret = $this->_sep . $this->_minus; $num = substr($num, 1); } // strip excessive zero signs $num = preg_replace('/^0+/', '', $num); if (strlen($num) > 6) { $current_power = 6; // check for highest power if (isset($this->_exponent[$power])) { // convert the number above the first 6 digits // with it's corresponding $power. $snum = substr($num, 0, -6); $snum = preg_replace('/^0+/', '', $snum); if ($snum !== '') { $ret .= $this->_toWords($snum, $power + 6); } } $num = substr($num, -6); if ($num == 0) { return $ret; } } elseif ($num == 0 || $num == '') { return(' '.$this->_digits[0]); $current_power = strlen($num); } else { $current_power = strlen($num); } // See if we need "thousands" $thousands = floor($num / 1000); if ($thousands == 1) { $ret .= $this->_sep . 'mil'; } elseif ($thousands > 1) { $ret .= $this->_toWords($thousands, 3); } // values for digits, tens and hundreds $h = floor(($num / 100) % 10); $t = floor(($num / 10) % 10); $d = floor($num % 10); // cientos: doscientos, trescientos, etc... switch ($h) { case 1: if (($d == 0) and ($t == 0)) { // is it's '100' use 'cien' $ret .= $this->_sep . 'cien'; } else { $ret .= $this->_sep . 'ciento'; } break; case 2: case 3: case 4: case 6: case 8: $ret .= $this->_sep . $this->_digits[$h] . 'cientos'; break; case 5: $ret .= $this->_sep . 'quinientos'; break; case 7: $ret .= $this->_sep . 'setecientos'; break; case 9: $ret .= $this->_sep . 'novecientos'; break; } // decenas: veinte, treinta, etc... switch ($t) { case 9: $ret .= $this->_sep . 'noventa'; break; case 8: $ret .= $this->_sep . 'ochenta'; break; case 7: $ret .= $this->_sep . 'setenta'; break; case 6: $ret .= $this->_sep . 'sesenta'; break; case 5: $ret .= $this->_sep . 'cincuenta'; break; case 4: $ret .= $this->_sep . 'cuarenta'; break; case 3: $ret .= $this->_sep . 'treinta'; break; case 2: if ($d == 0) { $ret .= $this->_sep . 'veinte'; } else { if (($power > 0) and ($d == 1)) { $ret .= $this->_sep . 'veintiún'; } else { $ret .= $this->_sep . 'veinti' . $this->_digits[$d]; } } break; case 1: switch ($d) { case 0: $ret .= $this->_sep . 'diez'; break; case 1: $ret .= $this->_sep . 'once'; break; case 2: $ret .= $this->_sep . 'doce'; break; case 3: $ret .= $this->_sep . 'trece'; break; case 4: $ret .= $this->_sep . 'catorce'; break; case 5: $ret .= $this->_sep . 'quince'; break; case 6: case 7: case 9: case 8: $ret .= $this->_sep . 'dieci' . $this->_digits[$d]; break; } break; } // add digits only if it is a multiple of 10 and not 1x or 2x if (($t != 1) and ($t != 2) and ($d > 0)) { // don't add 'y' for numbers below 10 if ($t != 0) { // use 'un' instead of 'uno' when there is a suffix ('mil', 'millones', etc...) if (($power > 0) and ($d == 1)) { $ret .= $this->_sep.' y un'; } else { $ret .= $this->_sep.'y '.$this->_digits[$d]; } } else { if (($power > 0) and ($d == 1)) { $ret .= $this->_sep.'un'; } else { $ret .= $this->_sep.$this->_digits[$d]; } } } if ($power > 0) { if (isset($this->_exponent[$power])) { $lev = $this->_exponent[$power]; } if (!isset($lev) || !is_array($lev)) { return null; } // if it's only one use the singular suffix if (($d == 1) and ($t == 0) and ($h == 0)) { $suffix = $lev[0]; } else { $suffix = $lev[1]; } if ($num != 0) { $ret .= $this->_sep . $suffix; } } return $ret; } // }}} } Numbers_Words-0.16.4/Numbers/Words/lang.es_AR.php0000644000076500007650000003436111732225114020227 0ustar igorigor * @author Martin Marrese * @license PHP 3.01 http://www.php.net/license/3_01.txt * @version SVN: $Id$ * @link http://pear.php.net/package/Numbers_Words */ /** * Class for translating numbers into Argentinian Spanish. * * @author Martin Marrese * @package Numbers_Words */ /** * Include needed files */ require_once "Numbers/Words.php"; /** * Class for translating numbers into Argentinian Spanish. * It supports up to decallones (10^6). * It doesn't support spanish tonic accents (acentos). * * @category Numbers * @package Numbers_Words * @author Xavier Noguer * @author Martin Marrese * @license PHP 3.01 http://www.php.net/license/3_01.txt * @link http://pear.php.net/package/Numbers_Words */ class Numbers_Words_es_AR extends Numbers_Words { // {{{ properties /** * Locale name * @var string * @access public */ var $locale = 'es_AR'; /** * Language name in English * @var string * @access public */ var $lang = 'Spanish'; /** * Native language name * @var string * @access public */ var $lang_native = 'Español'; /** * The word for the minus sign * @var string * @access private */ var $_minus = 'menos'; /** * The sufixes for exponents (singular and plural) * @var array * @access private */ var $_exponent = array( 0 => array('',''), 3 => array('mil','mil'), 6 => array('millón','millones'), 12 => array('billón','billones'), 18 => array('trilón','trillones'), 24 => array('cuatrillón','cuatrillones'), 30 => array('quintillón','quintillones'), 36 => array('sextillón','sextillones'), 42 => array('septillón','septillones'), 48 => array('octallón','octallones'), 54 => array('nonallón','nonallones'), 60 => array('decallón','decallones'), ); /** * The array containing the digits (indexed by the digits themselves). * @var array * @access private */ var $_digits = array( 0 => 'cero', 'uno', 'dos', 'tres', 'cuatro', 'cinco', 'seis', 'siete', 'ocho', 'nueve' ); /** * The word separator * @var string * @access private */ var $_sep = ' '; /** * The currency names (based on the below links, * informations from central bank websites and on encyclopedias) * * @var array * @link http://30-03-67.dreamstation.com/currency_alfa.htm World Currency Information * @link http://www.jhall.demon.co.uk/currency/by_abbrev.html World currencies * @link http://www.shoestring.co.kr/world/p.visa/change.htm Currency names in English * @access private */ var $_currency_names = array( 'ALL' => array(array('lek'), array('qindarka')), 'AUD' => array(array('Australian dollar'), array('cent')), 'ARS' => array(array('Peso'), array ('centavo')), 'BAM' => array(array('convertible marka'), array('fenig')), 'BGN' => array(array('lev'), array('stotinka')), 'BRL' => array(array('real'), array('centavos')), 'BYR' => array(array('Belarussian rouble'), array('kopiejka')), 'CAD' => array(array('Canadian dollar'), array('cent')), 'CHF' => array(array('Swiss franc'), array('rapp')), 'CYP' => array(array('Cypriot pound'), array('cent')), 'CZK' => array(array('Czech koruna'), array('halerz')), 'DKK' => array(array('Danish krone'), array('ore')), 'EEK' => array(array('kroon'), array('senti')), 'EUR' => array(array('euro'), array('euro-cent')), 'GBP' => array(array('pound', 'pounds'), array('pence')), 'HKD' => array(array('Hong Kong dollar'), array('cent')), 'HRK' => array(array('Croatian kuna'), array('lipa')), 'HUF' => array(array('forint'), array('filler')), 'ILS' => array(array('new sheqel','new sheqels'), array('agora','agorot')), 'ISK' => array(array('Icelandic króna'), array('aurar')), 'JPY' => array(array('yen'), array('sen')), 'LTL' => array(array('litas'), array('cent')), 'LVL' => array(array('lat'), array('sentim')), 'MKD' => array(array('Macedonian dinar'), array('deni')), 'MTL' => array(array('Maltese lira'), array('centym')), 'NOK' => array(array('Norwegian krone'), array('oere')), 'PLN' => array(array('zloty', 'zlotys'), array('grosz')), 'ROL' => array(array('Romanian leu'), array('bani')), 'RUB' => array(array('Russian Federation rouble'), array('kopiejka')), 'SEK' => array(array('Swedish krona'), array('oere')), 'SIT' => array(array('Tolar'), array('stotinia')), 'SKK' => array(array('Slovak koruna'), array()), 'TRL' => array(array('lira'), array('kuruþ')), 'UAH' => array(array('hryvna'), array('cent')), 'USD' => array(array('dollar'), array('cent')), 'YUM' => array(array('dinars'), array('para')), 'ZAR' => array(array('rand'), array('cent')) ); /** * The default currency name * @var string * @access public */ var $def_currency = 'ARS'; // Argentinian Peso // }}} // {{{ _toWords() /** * Converts a number to its word representation * in Argentinian Spanish. * * @param float $num An float between -infinity and infinity inclusive :) * that should be converted to a words representation * @param integer $power The power of ten for the rest of the number to the right. * For example toWords(12,3) should give "doce mil". * Optional, defaults to 0. * * @return string The corresponding word representation * * @access protected * @author Martin Marrese * @since Numbers_Words 0.16.3 */ function _toWords($num, $power = 0) { // The return string; $ret = ''; // add a the word for the minus sign if necessary if (substr($num, 0, 1) == '-') { $ret = $this->_sep . $this->_minus; $num = substr($num, 1); } // strip excessive zero signs $num = preg_replace('/^0+/', '', $num); $num_tmp = explode('.', $num); $num = $num_tmp[0]; $dec = (@$num_tmp[1]) ? $num_tmp[1] : ''; if (strlen($num) > 6) { $current_power = 6; // check for highest power if (isset($this->_exponent[$power])) { // convert the number above the first 6 digits // with it's corresponding $power. $snum = substr($num, 0, -6); $snum = preg_replace('/^0+/', '', $snum); if ($snum !== '') { $ret .= $this->_toWords($snum, $power + 6); } } $num = substr($num, -6); if ($num == 0) { return $ret; } } elseif ($num == 0 || $num == '') { return(' '.$this->_digits[0]); $current_power = strlen($num); } else { $current_power = strlen($num); } // See if we need "thousands" $thousands = floor($num / 1000); if ($thousands == 1) { $ret .= $this->_sep . 'mil'; } elseif ($thousands > 1) { $ret .= $this->_toWords($thousands, 3); } // values for digits, tens and hundreds $h = floor(($num / 100) % 10); $t = floor(($num / 10) % 10); $d = floor($num % 10); // cientos: doscientos, trescientos, etc... switch ($h) { case 1: if (($d == 0) and ($t == 0)) { // is it's '100' use 'cien' $ret .= $this->_sep . 'cien'; } else { $ret .= $this->_sep . 'ciento'; } break; case 2: case 3: case 4: case 6: case 8: $ret .= $this->_sep . $this->_digits[$h] . 'cientos'; break; case 5: $ret .= $this->_sep . 'quinientos'; break; case 7: $ret .= $this->_sep . 'setecientos'; break; case 9: $ret .= $this->_sep . 'novecientos'; break; } // decenas: veinte, treinta, etc... switch ($t) { case 9: $ret .= $this->_sep . 'noventa'; break; case 8: $ret .= $this->_sep . 'ochenta'; break; case 7: $ret .= $this->_sep . 'setenta'; break; case 6: $ret .= $this->_sep . 'sesenta'; break; case 5: $ret .= $this->_sep . 'cincuenta'; break; case 4: $ret .= $this->_sep . 'cuarenta'; break; case 3: $ret .= $this->_sep . 'treinta'; break; case 2: if ($d == 0) { $ret .= $this->_sep . 'veinte'; } else { if (($power > 0) and ($d == 1)) { $ret .= $this->_sep . 'veintiún'; } else { $ret .= $this->_sep . 'veinti' . $this->_digits[$d]; } } break; case 1: switch ($d) { case 0: $ret .= $this->_sep . 'diez'; break; case 1: $ret .= $this->_sep . 'once'; break; case 2: $ret .= $this->_sep . 'doce'; break; case 3: $ret .= $this->_sep . 'trece'; break; case 4: $ret .= $this->_sep . 'catorce'; break; case 5: $ret .= $this->_sep . 'quince'; break; case 6: case 7: case 9: case 8: $ret .= $this->_sep . 'dieci' . $this->_digits[$d]; break; } break; } // add digits only if it is a multiple of 10 and not 1x or 2x if (($t != 1) and ($t != 2) and ($d > 0)) { // don't add 'y' for numbers below 10 if ($t != 0) { // use 'un' instead of 'uno' when there is a suffix ('mil', 'millones', etc...) if (($power > 0) and ($d == 1)) { $ret .= $this->_sep.' y un'; } else { $ret .= $this->_sep.'y '.$this->_digits[$d]; } } else { if (($power > 0) and ($d == 1)) { $ret .= $this->_sep.'un'; } else { $ret .= $this->_sep.$this->_digits[$d]; } } } if ($power > 0) { if (isset($this->_exponent[$power])) { $lev = $this->_exponent[$power]; } if (!isset($lev) || !is_array($lev)) { return null; } // if it's only one use the singular suffix if (($d == 1) and ($t == 0) and ($h == 0)) { $suffix = $lev[0]; } else { $suffix = $lev[1]; } if ($num != 0) { $ret .= $this->_sep . $suffix; } } if ($dec) { $dec = $this->_toWords(trim($dec)); $ret .= ' con ' . trim($dec); } return $ret; } // }}} // {{{ toCurrencyWords() /** * Converts a currency value to its word representation * (with monetary units) in Agentinian Spanish language * * @param integer $int_curr An international currency symbol * as defined by the ISO 4217 standard (three characters) * @param integer $decimal A money total amount without fraction part (e.g. amount of dollars) * @param integer $fraction Fractional part of the money amount (e.g. amount of cents) * Optional. Defaults to false. * @param integer $convert_fraction Convert fraction to words (left as numeric if set to false). * Optional. Defaults to true. * * @return string The corresponding word representation for the currency * * @access public * @author Martin Marrese */ function toCurrencyWords($int_curr, $decimal, $fraction = false, $convert_fraction = true) { $int_curr = strtoupper($int_curr); if (!isset($this->_currency_names[$int_curr])) { $int_curr = $this->def_currency; } $curr_names = $this->_currency_names[$int_curr]; $lev = ($decimal == 1) ? 0 : 1; if ($lev > 0) { if (count($curr_names[0]) > 1) { $ret = $curr_names[0][$lev]; } else { $ret = $curr_names[0][0] . 's'; } } else { $ret = $curr_names[0][0]; } $ret .= $this->_sep . trim($this->_toWords($decimal)); if ($fraction !== false) { if ($convert_fraction) { $ret .= $this->_sep .'con'. $this->_sep . trim($this->_toWords($fraction)); } else { $ret .= $this->_sep .'con'. $this->_sep . $fraction; } $lev = ($fraction == 1) ? 0 : 1; if ($lev > 0) { if (count($curr_names[1]) > 1) { $ret .= $this->_sep . $curr_names[1][$lev]; } else { $ret .= $this->_sep . $curr_names[1][0] . 's'; } } else { $ret .= $this->_sep . $curr_names[1][0]; } } return $ret; } // }}} } Numbers_Words-0.16.4/Numbers/Words/lang.es_MX.php0000644000076500007650000003455311732225114020254 0ustar igorigor * @author Martin Marrese * @license PHP 3.01 http://www.php.net/license/3_01.txt * @version SVN: $Id: lang.es_AR.php 269823 2008-11-25 13:47:38Z clockwerx $ * @link http://pear.php.net/package/Numbers_Words */ /** * Class for translating numbers into Mexican Spanish. * * @author Martin Marrese * @package Numbers_Words */ /** * Include needed files */ require_once "Numbers/Words.php"; /** * Class for translating numbers into Argentinian Spanish. * It supports up to decallones (10^6). * It doesn't support spanish tonic accents (acentos). * * @category Numbers * @package Numbers_Words * @author Pavel Oropeza * @author Martin Marrese * @license PHP 3.01 http://www.php.net/license/3_01.txt * @link http://pear.php.net/package/Numbers_Words */ class Numbers_Words_es_MX extends Numbers_Words { // {{{ properties /** * Locale name * @var string * @access public */ var $locale = 'es_MX'; /** * Language name in English * @var string * @access public */ var $lang = 'Spanish'; /** * Native language name * @var string * @access public */ var $lang_native = 'Español'; /** * The word for the minus sign * @var string * @access private */ var $_minus = 'menos'; /** * The sufixes for exponents (singular and plural) * @var array * @access private */ var $_exponent = array( 0 => array('',''), 3 => array('mil','mil'), 6 => array('millón','millones'), 12 => array('billón','billones'), 18 => array('trilón','trillones'), 24 => array('cuatrillón','cuatrillones'), 30 => array('quintillón','quintillones'), 36 => array('sextillón','sextillones'), 42 => array('septillón','septillones'), 48 => array('octallón','octallones'), 54 => array('nonallón','nonallones'), 60 => array('decallón','decallones'), ); /** * The array containing the digits (indexed by the digits themselves). * @var array * @access private */ var $_digits = array( 0 => 'cero', 'un', 'dos', 'tres', 'cuatro', 'cinco', 'seis', 'siete', 'ocho', 'nueve' ); /** * The word separator * @var string * @access private */ var $_sep = ' '; /** * The currency names (based on the below links, * informations from central bank websites and on encyclopedias) * * @var array * @link http://30-03-67.dreamstation.com/currency_alfa.htm World Currency Information * @link http://www.jhall.demon.co.uk/currency/by_abbrev.html World currencies * @link http://www.shoestring.co.kr/world/p.visa/change.htm Currency names in English * @access private */ var $_currency_names = array( 'ALL' => array(array('lek'), array('qindarka')), 'AUD' => array(array('Australian dollar'), array('cent')), 'ARS' => array(array('Peso'), array ('centavo')), 'BAM' => array(array('convertible marka'), array('fenig')), 'BGN' => array(array('lev'), array('stotinka')), 'BRL' => array(array('real'), array('centavos')), 'BYR' => array(array('Belarussian rouble'), array('kopiejka')), 'CAD' => array(array('Canadian dollar'), array('cent')), 'CHF' => array(array('Swiss franc'), array('rapp')), 'CYP' => array(array('Cypriot pound'), array('cent')), 'CZK' => array(array('Czech koruna'), array('halerz')), 'DKK' => array(array('Danish krone'), array('ore')), 'EEK' => array(array('kroon'), array('senti')), 'EUR' => array(array('euro'), array('euro-cent')), 'GBP' => array(array('pound', 'pounds'), array('pence')), 'HKD' => array(array('Hong Kong dollar'), array('cent')), 'HRK' => array(array('Croatian kuna'), array('lipa')), 'HUF' => array(array('forint'), array('filler')), 'ILS' => array(array('new sheqel','new sheqels'), array('agora','agorot')), 'ISK' => array(array('Icelandic króna'), array('aurar')), 'JPY' => array(array('yen'), array('sen')), 'LTL' => array(array('litas'), array('cent')), 'LVL' => array(array('lat'), array('sentim')), 'MKD' => array(array('Macedonian dinar'), array('deni')), 'MTL' => array(array('Maltese lira'), array('centym')), 'MXN' => array(array('peso'), array ('centavo')), 'NOK' => array(array('Norwegian krone'), array('oere')), 'PLN' => array(array('zloty', 'zlotys'), array('grosz')), 'ROL' => array(array('Romanian leu'), array('bani')), 'RUB' => array(array('Russian Federation rouble'), array('kopiejka')), 'SEK' => array(array('Swedish krona'), array('oere')), 'SIT' => array(array('Tolar'), array('stotinia')), 'SKK' => array(array('Slovak koruna'), array()), 'TRL' => array(array('lira'), array('kuruþ')), 'UAH' => array(array('hryvna'), array('cent')), 'USD' => array(array('dollar'), array('cent')), 'YUM' => array(array('dinars'), array('para')), 'ZAR' => array(array('rand'), array('cent')) ); /** * The default currency name * @var string * @access public */ var $def_currency = 'MXN'; // Mexican Peso // }}} // {{{ _toWords() /** * Converts a number to its word representation * in Mexican Spanish. * * @param float $num An float between -infinity and infinity inclusive :) * that should be converted to a words representation * @param integer $power The power of ten for the rest of the number to the right. * For example toWords(12,3) should give "doce mil". * Optional, defaults to 0. * * @return string The corresponding word representation * * @access protected * @author Martin Marrese * @since Numbers_Words 0.16.3 */ function _toWords($num, $power = 0) { // The return string; $ret = ''; // add a the word for the minus sign if necessary if (substr($num, 0, 1) == '-') { $ret = $this->_sep . $this->_minus; $num = substr($num, 1); } // strip excessive zero signs $num = preg_replace('/^0+/', '', $num); $num_tmp = explode('.', $num); $num = $num_tmp[0]; $dec = (@$num_tmp[1]) ? $num_tmp[1] : ''; if (strlen($num) > 6) { $current_power = 6; // check for highest power if (isset($this->_exponent[$power])) { // convert the number above the first 6 digits // with it's corresponding $power. $snum = substr($num, 0, -6); $snum = preg_replace('/^0+/', '', $snum); if ($snum !== '') { $ret .= $this->_toWords($snum, $power + 6); } } $num = substr($num, -6); if ($num == 0) { return $ret; } } elseif ($num == 0 || $num == '') { return(' '.$this->_digits[0]); $current_power = strlen($num); } else { $current_power = strlen($num); } // See if we need "thousands" $thousands = floor($num / 1000); if ($thousands == 1) { $ret .= $this->_sep . 'mil'; } elseif ($thousands > 1) { $ret .= $this->_toWords($thousands, 3); } // values for digits, tens and hundreds $h = floor(($num / 100) % 10); $t = floor(($num / 10) % 10); $d = floor($num % 10); // cientos: doscientos, trescientos, etc... switch ($h) { case 1: if (($d == 0) and ($t == 0)) { // is it's '100' use 'cien' $ret .= $this->_sep . 'cien'; } else { $ret .= $this->_sep . 'ciento'; } break; case 2: case 3: case 4: case 6: case 8: $ret .= $this->_sep . $this->_digits[$h] . 'cientos'; break; case 5: $ret .= $this->_sep . 'quinientos'; break; case 7: $ret .= $this->_sep . 'setecientos'; break; case 9: $ret .= $this->_sep . 'novecientos'; break; } // decenas: veinte, treinta, etc... switch ($t) { case 9: $ret .= $this->_sep . 'noventa'; break; case 8: $ret .= $this->_sep . 'ochenta'; break; case 7: $ret .= $this->_sep . 'setenta'; break; case 6: $ret .= $this->_sep . 'sesenta'; break; case 5: $ret .= $this->_sep . 'cincuenta'; break; case 4: $ret .= $this->_sep . 'cuarenta'; break; case 3: $ret .= $this->_sep . 'treinta'; break; case 2: if ($d == 0) { $ret .= $this->_sep . 'veinte'; } else { if (($power > 0) and ($d == 1)) { $ret .= $this->_sep . 'veintiún'; } else { $ret .= $this->_sep . 'veinti' . $this->_digits[$d]; } } break; case 1: switch ($d) { case 0: $ret .= $this->_sep . 'diez'; break; case 1: $ret .= $this->_sep . 'once'; break; case 2: $ret .= $this->_sep . 'doce'; break; case 3: $ret .= $this->_sep . 'trece'; break; case 4: $ret .= $this->_sep . 'catorce'; break; case 5: $ret .= $this->_sep . 'quince'; break; case 6: case 7: case 9: case 8: $ret .= $this->_sep . 'dieci' . $this->_digits[$d]; break; } break; } // add digits only if it is a multiple of 10 and not 1x or 2x if (($t != 1) and ($t != 2) and ($d > 0)) { // don't add 'y' for numbers below 10 if ($t != 0) { // use 'un' instead of 'uno' when there is a suffix ('mil', 'millones', etc...) if (($power > 0) and ($d == 1)) { $ret .= $this->_sep.' y un'; } else { $ret .= $this->_sep.'y '.$this->_digits[$d]; } } else { if (($power > 0) and ($d == 1)) { $ret .= $this->_sep.'un'; } else { $ret .= $this->_sep.$this->_digits[$d]; } } } if ($power > 0) { if (isset($this->_exponent[$power])) { $lev = $this->_exponent[$power]; } if (!isset($lev) || !is_array($lev)) { return null; } // if it's only one use the singular suffix if (($d == 1) and ($t == 0) and ($h == 0)) { $suffix = $lev[0]; } else { $suffix = $lev[1]; } if ($num != 0) { $ret .= $this->_sep . $suffix; } } if ($dec) { $dec = $this->_toWords(trim($dec)); $ret .= ' con ' . trim($dec); } return $ret; } /** * Converts a currency value to its word representation * (with monetary units) in Mexican Spanish language * * @param integer $int_curr An international currency symbol * as defined by the ISO 4217 standard (three characters) * @param integer $decimal A money total amount without fraction part (e.g. amount of dollars) * @param integer $fraction Fractional part of the money amount (e.g. amount of cents) * Optional. Defaults to false. * @param integer $convert_fraction Convert fraction to words (left as numeric if set to false). * Optional. Defaults to true. * * @return string The corresponding word representation for the currency * * @access public * @author Pavel Oropeza */ function toCurrencyWords($int_curr, $decimal, $fraction = false, $convert_fraction = true) { if (!isset($this->_currency_names[$int_curr])) { $int_curr = $this->def_currency; } $curr_names = $this->_currency_names[$int_curr]; $lev = ($decimal == 1) ? 0 : 1; if ($lev > 0) { $curr_names = $this->_currency_names[$int_curr]; if (count($curr_names[0]) > 1) { $ret = $curr_names[0][$lev]; } else { $ret = $curr_names[0][0] . 's'; } } else { $ret = $curr_names[0][0]; } $ret = $this->_sep . ucfirst(trim($this->_toWords($decimal) ." " . $ret)); if ($fraction !== false) { if ($convert_fraction) { $ret .= $this->_sep .'con'. $this->_sep . trim($this->_toWords($fraction)); } else { $ret .= $this->_sep .'con'. $this->_sep . $fraction; } $lev = ($fraction == 1) ? 0 : 1; if ($lev > 0) { if (count($curr_names[1]) > 1) { $ret .= $this->_sep . $curr_names[1][$lev]; } else { $ret .= $this->_sep . $curr_names[1][0] . 's'; } } else { $ret .= $this->_sep . $curr_names[1][0]; } } return $ret; } } Numbers_Words-0.16.4/Numbers/Words/lang.et.php0000644000076500007650000002473411732225114017651 0ustar igorigor * @license PHP 3.01 http://www.php.net/license/3_01.txt * @version SVN: $Id$ * @link http://pear.php.net/package/Numbers_Words */ require_once "Numbers/Words.php"; /** * Class for translating numbers into Estonian. * * @category Numbers * @package Numbers_Words * @author Erkki Saarniit * @license PHP 3.01 http://www.php.net/license/3_01.txt * @link http://pear.php.net/package/Numbers_Words */ class Numbers_Words_et extends Numbers_Words { // {{{ properties /** * Locale name * @var string * @access public */ var $locale = 'et'; /** * Language name in English * @var string * @access public */ var $lang = 'Estonian'; /** * Native language name * @var string * @access public */ var $lang_native = 'eesti keel'; /** * The word for the minus sign * @var string * @access private */ var $_minus = 'miinus'; // minus sign /** * The sufixes for exponents (singular and plural) * Names partly based on: * http://home.earthlink.net/~mrob/pub/math/largenum.html * http://mathforum.org/dr.math/faq/faq.large.numbers.html * http://www.mazes.com/AmericanNumberingSystem.html * @var array * @access private */ var $_exponent = array( 0 => array(''), 3 => array('tuhat'), 6 => array('miljon'), 9 => array('miljard'), 12 => array('triljon'), 15 => array('kvadriljon'), 18 => array('kvintiljon'), 21 => array('sekstiljon'), 24 => array('septiljon'), 27 => array('oktiljon'), 30 => array('noniljon'), 33 => array('dekiljon'), 36 => array('undekiljon'), 39 => array('duodekiljon'), 42 => array('tredekiljon'), 45 => array('kvattuordekiljon'), 48 => array('kvindekiljon'), 51 => array('seksdekiljon'), 54 => array('septendekiljon'), 57 => array('oktodekiljon'), 60 => array('novemdekiljon'), 63 => array('vigintiljon'), 66 => array('unvigintiljon'), 69 => array('duovigintiljon'), 72 => array('trevigintiljon'), 75 => array('kvattuorvigintiljon'), 78 => array('kvinvigintiljon'), 81 => array('seksvigintiljon'), 84 => array('septenvigintiljon'), 87 => array('oktovigintiljon'), 90 => array('novemvigintiljon'), 93 => array('trigintiljon'), 96 => array('untrigintiljon'), 99 => array('duotrigintiljon'), 102 => array('trestrigintiljon'), 105 => array('kvattuortrigintiljon'), 108 => array('kvintrigintiljon'), 111 => array('sekstrigintiljon'), 114 => array('septentrigintiljon'), 117 => array('oktotrigintiljon'), 120 => array('novemtrigintiljon'), 123 => array('kvadragintiljon'), 126 => array('unkvadragintiljon'), 129 => array('duokvadragintiljon'), 132 => array('trekvadragintiljon'), 135 => array('kvattuorkvadragintiljon'), 138 => array('kvinkvadragintiljon'), 141 => array('sekskvadragintiljon'), 144 => array('septenkvadragintiljon'), 147 => array('oktokvadragintiljon'), 150 => array('novemkvadragintiljon'), 153 => array('kvinkvagintiljon'), 156 => array('unkvinkvagintiljon'), 159 => array('duokvinkvagintiljon'), 162 => array('trekvinkvagintiljon'), 165 => array('kvattuorkvinkvagintiljon'), 168 => array('kvinkvinkvagintiljon'), 171 => array('sekskvinkvagintiljon'), 174 => array('septenkvinkvagintiljon'), 177 => array('oktokvinkvagintiljon'), 180 => array('novemkvinkvagintiljon'), 183 => array('seksagintiljon'), 186 => array('unseksagintiljon'), 189 => array('duoseksagintiljon'), 192 => array('treseksagintiljon'), 195 => array('kvattuorseksagintiljon'), 198 => array('kvinseksagintiljon'), 201 => array('seksseksagintiljon'), 204 => array('septenseksagintiljon'), 207 => array('oktoseksagintiljon'), 210 => array('novemseksagintiljon'), 213 => array('septuagintiljon'), 216 => array('unseptuagintiljon'), 219 => array('duoseptuagintiljon'), 222 => array('treseptuagintiljon'), 225 => array('kvattuorseptuagintiljon'), 228 => array('kvinseptuagintiljon'), 231 => array('seksseptuagintiljon'), 234 => array('septenseptuagintiljon'), 237 => array('oktoseptuagintiljon'), 240 => array('novemseptuagintiljon'), 243 => array('oktogintiljon'), 246 => array('unoktogintiljon'), 249 => array('duooktogintiljon'), 252 => array('treoktogintiljon'), 255 => array('kvattuoroktogintiljon'), 258 => array('kvinoktogintiljon'), 261 => array('seksoktogintiljon'), 264 => array('septoktogintiljon'), 267 => array('oktooktogintiljon'), 270 => array('novemoktogintiljon'), 273 => array('nonagintiljon'), 276 => array('unnonagintiljon'), 279 => array('duononagintiljon'), 282 => array('trenonagintiljon'), 285 => array('kvattuornonagintiljon'), 288 => array('kvinnonagintiljon'), 291 => array('seksnonagintiljon'), 294 => array('septennonagintiljon'), 297 => array('oktononagintiljon'), 300 => array('novemnonagintiljon'), 303 => array('kentiljon'), 309 => array('duokentiljon'), 312 => array('trekentiljon'), 366 => array('primo-vigesimo-kentiljon'), 402 => array('trestrigintakentiljon'), 603 => array('dukentiljon'), 624 => array('septendukentiljon'), 2421 => array('seksoktingentiljon'), 3003 => array('milliljon'), 3000003 => array('milli-milliljon')); /** * The array containing the digits (indexed by the digits themselves). * @var array * @access private */ var $_digits = array( 0 => 'null', 'üks', 'kaks', 'kolm', 'neli', 'viis', 'kuus', 'seitse', 'kaheksa', 'üheksa' ); /** * The word separator * @var string * @access private */ var $_sep = ' '; // }}} // {{{ _toWords() /** * Converts a number to its word representation * in Estonian language * * @param integer $num An integer between -infinity and infinity inclusive :) * that need to be converted to words * @param integer $power The power of ten for the rest of the number to the right. * Optional, defaults to 0. * @param integer $powsuffix The power name to be added to the end of the return string. * Used internally. Optional, defaults to ''. * * @return string The corresponding word representation * * @access protected * @since Numbers_Words 0.16.3 */ function _toWords($num, $power = 0, $powsuffix = '') { $ret = ''; if (substr($num, 0, 1) == '-') { $ret = $this->_sep . $this->_minus; $num = substr($num, 1); } $num = trim($num); $num = preg_replace('/^0+/', '', $num); if (strlen($num) > 3) { $maxp = strlen($num) - 1; $curp = $maxp; for ($p = $maxp; $p > 0; --$p) { // power if (isset($this->_exponent[$p])) { $snum = substr($num, $maxp - $curp, $curp - $p + 1); $snum = preg_replace('/^0+/', '', $snum); if ($snum !== '') { $cursuffix = $this->_exponent[$power][count($this->_exponent[$power])-1]; if ($powsuffix != '') { $cursuffix .= $this->_sep . $powsuffix; } $ret .= $this->_toWords($snum, $p, $cursuffix); } $curp = $p - 1; continue; } } $num = substr($num, $maxp - $curp, $curp - $p + 1); if ($num == 0) { return $ret; } } elseif ($num == 0 || $num == '') { return $this->_sep . $this->_digits[0]; } $h = $t = $d = 0; switch(strlen($num)) { case 3: $h = (int)substr($num, -3, 1); case 2: $t = (int)substr($num, -2, 1); case 1: $d = (int)substr($num, -1, 1); break; case 0: return; break; } if ($h) { $ret .= $this->_sep . $this->_digits[$h] . 'sada'; } switch ($t) { case 9: case 8: case 7: case 6: case 5: case 4: case 3: case 2: $ret .= $this->_sep . $this->_digits[$t] . 'kümmend'; break; case 1: switch ($d) { case 0: $ret .= $this->_sep . 'kümme'; break; case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: $ret .= $this->_sep . $this->_digits[$d] . 'teist'; break; } break; } if ($t != 1 && $d > 0) { if ($t > 1) { $ret .= ' ' . $this->_digits[$d]; } else { $ret .= $this->_sep . $this->_digits[$d]; } } if ($power > 0) { if (isset($this->_exponent[$power])) { $lev = $this->_exponent[$power]; } if (!isset($lev) || !is_array($lev)) { return null; } $ret .= $this->_sep . $lev[0].($num != 1 && $power!= 3 ? 'it' : ''); } if ($powsuffix != '') { $ret .= $this->_sep . $powsuffix; } return $ret; } // }}} } Numbers_Words-0.16.4/Numbers/Words/lang.fr.php0000644000076500007650000003075011732225114017643 0ustar igorigor * @license PHP 3.01 http://www.php.net/license/3_01.txt * @version SVN: $Id$ * @link http://pear.php.net/package/Numbers_Words */ /** * Include needed files */ require_once "Numbers/Words.php"; /** * Class for translating numbers into French. * * @category Numbers * @package Numbers_Words * @author Kouber Saparev * @license PHP 3.01 http://www.php.net/license/3_01.txt * @link http://pear.php.net/package/Numbers_Words */ class Numbers_Words_fr extends Numbers_Words { // {{{ properties /** * Locale name. * @var string * @access public */ var $locale = 'fr'; /** * Language name in English. * @var string * @access public */ var $lang = 'French'; /** * Native language name. * @var string * @access public */ var $lang_native = 'Français'; /** * The words for some numbers. * @var string * @access private */ var $_misc_numbers = array( 10=>'dix', // 10 'onze', // 11 'douze', // 12 'treize', // 13 'quatorze', // 14 'quinze', // 15 'seize', // 16 20=>'vingt', // 20 30=>'trente', // 30 40=>'quarante', // 40 50=>'cinquante',// 50 60=>'soixante', // 60 100=>'cent' // 100 ); /** * The words for digits (except zero). * @var string * @access private */ var $_digits = array(1=>"un", "deux", "trois", "quatre", "cinq", "six", "sept", "huit", "neuf"); /** * The word for zero. * @var string * @access private */ var $_zero = 'zéro'; /** * The word for infinity. * @var string * @access private */ var $_infinity = 'infini'; /** * The word for the "and" language construct. * @var string * @access private */ var $_and = 'et'; /** * The word separator. * @var string * @access private */ var $_sep = ' '; /** * The dash liaison. * @var string * @access private */ var $_dash = '-'; /** * The word for the minus sign. * @var string * @access private */ var $_minus = 'moins'; // minus sign /** * The plural suffix (except for hundred). * @var string * @access private */ var $_plural = 's'; // plural suffix /** * The suffixes for exponents (singular). * @var array * @access private */ var $_exponent = array( 0 => '', 3 => 'mille', 6 => 'million', 9 => 'milliard', 12 => 'trillion', 15 => 'quadrillion', 18 => 'quintillion', 21 => 'sextillion', 24 => 'septillion', 27 => 'octillion', 30 => 'nonillion', 33 => 'decillion', 36 => 'undecillion', 39 => 'duodecillion', 42 => 'tredecillion', 45 => 'quattuordecillion', 48 => 'quindecillion', 51 => 'sexdecillion', 54 => 'septendecillion', 57 => 'octodecillion', 60 => 'novemdecillion', 63 => 'vigintillion', 66 => 'unvigintillion', 69 => 'duovigintillion', 72 => 'trevigintillion', 75 => 'quattuorvigintillion', 78 => 'quinvigintillion', 81 => 'sexvigintillion', 84 => 'septenvigintillion', 87 => 'octovigintillion', 90 => 'novemvigintillion', 93 => 'trigintillion', 96 => 'untrigintillion', 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', 183 => 'sexagintillion', 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', 243 => 'octogintillion', 246 => 'unoctogintillion', 249 => 'duooctogintillion', 252 => 'treoctogintillion', 255 => 'quattuoroctogintillion', 258 => 'quinoctogintillion', 261 => 'sexoctogintillion', 264 => 'septoctogintillion', 267 => 'octooctogintillion', 270 => 'novemoctogintillion', 273 => 'nonagintillion', 276 => 'unnonagintillion', 279 => 'duononagintillion', 282 => 'trenonagintillion', 285 => 'quattuornonagintillion', 288 => 'quinnonagintillion', 291 => 'sexnonagintillion', 294 => 'septennonagintillion', 297 => 'octononagintillion', 300 => 'novemnonagintillion', 303 => 'centillion' ); // }}} // {{{ _splitNumber() /** * Split a number to groups of three-digit numbers. * * @param mixed $num An integer or its string representation * that need to be split * * @return array Groups of three-digit numbers. * @access private * @author Kouber Saparev * @since PHP 4.2.3 */ function _splitNumber($num) { if (is_string($num)) { $ret = array(); $strlen = strlen($num); $first = substr($num, 0, $strlen%3); preg_match_all('/\d{3}/', substr($num, $strlen%3, $strlen), $m); $ret =& $m[0]; if ($first) { array_unshift($ret, $first); } return $ret; } return explode(' ', number_format($num, 0, '', ' ')); // a faster version for integers } // }}} // {{{ _showDigitsGroup() /** * Converts a three-digit number to its word representation * in French language. * * @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. * @access private * @author Kouber Saparev */ function _showDigitsGroup($num, $last = false) { $ret = ''; // extract the value of each digit from the three-digit number $e = $num%10; // ones $d = ($num-$e)%100/10; // tens $s = ($num-$d*10-$e)%1000/100; // hundreds // process the "hundreds" digit. if ($s) { if ($s>1) { $ret .= $this->_digits[$s].$this->_sep.$this->_misc_numbers[100]; if ($last && !$e && !$d) { $ret .= $this->_plural; } } else { $ret .= $this->_misc_numbers[100]; } $ret .= $this->_sep; } // process the "tens" digit, and optionally the "ones" digit. if ($d) { // in the case of 1, the "ones" digit also must be processed if ($d==1) { if ($e<=6) { $ret .= $this->_misc_numbers[10+$e]; } else { $ret .= $this->_misc_numbers[10].'-'.$this->_digits[$e]; } $e = 0; } elseif ($d>5) { if ($d<8) { $ret .= $this->_misc_numbers[60]; $resto = $d*10+$e-60; if ($e==1) { $ret .= $this->_sep.$this->_and.$this->_sep; } elseif ($resto) { $ret .= $this->_dash; } if ($resto) { $ret .= $this->_showDigitsGroup($resto); } $e = 0; } else { $ret .= $this->_digits[4].$this->_dash.$this->_misc_numbers[20]; $resto = $d*10+$e-80; if ($resto) { $ret .= $this->_dash; $ret .= $this->_showDigitsGroup($resto); $e = 0; } else { $ret .= $this->_plural; } } } else { $ret .= $this->_misc_numbers[$d*10]; } } // process the "ones" digit if ($e) { if ($d) { if ($e==1) { $ret .= $this->_sep.$this->_and.$this->_sep; } else { $ret .= $this->_dash; } } $ret .= $this->_digits[$e]; } // strip excessive separators $ret = rtrim($ret, $this->_sep); return $ret; } // }}} // {{{ _toWords() /** * Converts a number to its word representation * in French language. * * @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 * @access protected * @author Kouber Saparev * @since Numbers_Words 0.16.3 */ function _toWords($num = 0) { $ret = ''; // check if $num is a valid non-zero number if (!$num || preg_match('/^-?0+$/', $num) || !preg_match('/^-?\d+$/', $num)) { return $this->_zero; } // add a minus sign if (substr($num, 0, 1) == '-') { $ret = $this->_minus . $this->_sep; $num = substr($num, 1); } // if the absolute value is greater than 9.99*10^302, return infinity if (strlen($num)>306) { return $ret . $this->_infinity; } // strip excessive zero signs $num = ltrim($num, '0'); // 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!='000') { 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) { $ret .= $this->_plural; } $ret .= $this->_sep; } } return rtrim($ret, $this->_sep); } // }}} } Numbers_Words-0.16.4/Numbers/Words/lang.fr_BE.php0000644000076500007650000003006211732225114020205 0ustar igorigor * @author Philippe Bajoit * @author Philippe Bajoit 'dix', // 10 'onze', // 11 'douze', // 12 'treize', // 13 'quatorze', // 14 'quinze', // 15 'seize', // 16 20=>'vingt', // 20 30=>'trente', // 30 40=>'quarante', // 40 50=>'cinquante',// 50 60=>'soixante', // 60 70=>'septante', // 70 90=>'nonante', // 90 100=>'cent' // 100 ); /** * The words for digits (except zero). * @var string * @access private */ var $_digits = array(1=>"un", "deux", "trois", "quatre", "cinq", "six", "sept", "huit", "neuf"); /** * The word for zero. * @var string * @access private */ var $_zero = 'zéro'; /** * The word for infinity. * @var string * @access private */ var $_infinity = 'infini'; /** * The word for the "and" language construct. * @var string * @access private */ var $_and = 'et'; /** * The word separator. * @var string * @access private */ var $_sep = ' '; /** * The dash liaison. * @var string * @access private */ var $_dash = '-'; /** * The word for the minus sign. * @var string * @access private */ var $_minus = 'moins'; // minus sign /** * The plural suffix (except for hundred). * @var string * @access private */ var $_plural = 's'; // plural suffix /** * The suffixes for exponents (singular). * @var array * @access private */ var $_exponent = array( 0 => '', 3 => 'mille', 6 => 'million', 9 => 'milliard', 12 => 'trillion', 15 => 'quadrillion', 18 => 'quintillion', 21 => 'sextillion', 24 => 'septillion', 27 => 'octillion', 30 => 'nonillion', 33 => 'decillion', 36 => 'undecillion', 39 => 'duodecillion', 42 => 'tredecillion', 45 => 'quattuordecillion', 48 => 'quindecillion', 51 => 'sexdecillion', 54 => 'septendecillion', 57 => 'octodecillion', 60 => 'novemdecillion', 63 => 'vigintillion', 66 => 'unvigintillion', 69 => 'duovigintillion', 72 => 'trevigintillion', 75 => 'quattuorvigintillion', 78 => 'quinvigintillion', 81 => 'sexvigintillion', 84 => 'septenvigintillion', 87 => 'octovigintillion', 90 => 'novemvigintillion', 93 => 'trigintillion', 96 => 'untrigintillion', 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', 183 => 'sexagintillion', 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', 243 => 'octogintillion', 246 => 'unoctogintillion', 249 => 'duooctogintillion', 252 => 'treoctogintillion', 255 => 'quattuoroctogintillion', 258 => 'quinoctogintillion', 261 => 'sexoctogintillion', 264 => 'septoctogintillion', 267 => 'octooctogintillion', 270 => 'novemoctogintillion', 273 => 'nonagintillion', 276 => 'unnonagintillion', 279 => 'duononagintillion', 282 => 'trenonagintillion', 285 => 'quattuornonagintillion', 288 => 'quinnonagintillion', 291 => 'sexnonagintillion', 294 => 'septennonagintillion', 297 => 'octononagintillion', 300 => 'novemnonagintillion', 303 => 'centillion' ); // }}} // {{{ _splitNumber() /** * Split a number to groups of three-digit numbers. * * @param mixed $num An integer or its string representation * that need to be split * * @return array Groups of three-digit numbers. * @access private * @author Kouber Saparev * @since PHP 4.2.3 */ function _splitNumber($num) { if (is_string($num)) { $ret = array(); $strlen = strlen($num); $first = substr($num, 0, $strlen%3); preg_match_all('/\d{3}/', substr($num, $strlen%3, $strlen), $m); $ret =& $m[0]; if ($first) { array_unshift($ret, $first); } return $ret; } return explode(' ', number_format($num, 0, '', ' ')); // a faster version for integers } // }}} // {{{ _showDigitsGroup() /** * Converts a three-digit number to its word representation * in French language. * * @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. * @access private * @author Kouber Saparev */ function _showDigitsGroup($num, $last = false) { $ret = ''; // extract the value of each digit from the three-digit number $e = $num%10; // ones $d = ($num-$e)%100/10; // tens $s = ($num-$d*10-$e)%1000/100; // hundreds // process the "hundreds" digit. if ($s) { if ($s>1) { $ret .= $this->_digits[$s].$this->_sep.$this->_misc_numbers[100]; if ($last && !$e && !$d) { $ret .= $this->_plural; } } else { $ret .= $this->_misc_numbers[100]; } $ret .= $this->_sep; } // process the "tens" digit, and optionally the "ones" digit. if ($d) { // in the case of 1, the "ones" digit also must be processed if ($d==1) { if ($e<=6) { $ret .= $this->_misc_numbers[10+$e]; } else { $ret .= $this->_misc_numbers[10].'-'.$this->_digits[$e]; } $e = 0; } elseif ($d==8) { $ret .= $this->_digits[4].$this->_dash.$this->_misc_numbers[20]; $resto = $d*10+$e-80; if ($resto) { $ret .= $this->_dash; $ret .= $this->_showDigitsGroup($resto); $e = 0; } else { $ret .= $this->_plural; } } else { $ret .= $this->_misc_numbers[$d*10]; } } // process the "ones" digit if ($e) { if ($d) { if ($e==1) { $ret .= $this->_sep.$this->_and.$this->_sep; } else { $ret .= $this->_dash; } } $ret .= $this->_digits[$e]; } // strip excessive separators $ret = rtrim($ret, $this->_sep); return $ret; } // }}} // {{{ _toWords() /** * Converts a number to its word representation * in French language. * * @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 * @access protected * @author Kouber Saparev * @since Numbers_Words 0.16.3 */ function _toWords($num = 0) { $ret = ''; // check if $num is a valid non-zero number if (!$num || preg_match('/^-?0+$/', $num) || !preg_match('/^-?\d+$/', $num)) { return $this->_zero; } // add a minus sign if (substr($num, 0, 1) == '-') { $ret = $this->_minus . $this->_sep; $num = substr($num, 1); } // if the absolute value is greater than 9.99*10^302, return infinity if (strlen($num)>306) { return $ret . $this->_infinity; } // strip excessive zero signs $num = ltrim($num, '0'); // 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!='000') { 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) { $ret .= $this->_plural; } $ret .= $this->_sep; } } return rtrim($ret, $this->_sep); } // }}} } Numbers_Words-0.16.4/Numbers/Words/lang.he.php0000644000076500007650000004270211732225114017630 0ustar igorigor * @license PHP 3.01 http://www.php.net/license/3_01.txt * @version SVN: $Id$ * @link http://pear.php.net/package/Numbers_Words */ /** * Class for translating numbers into Hebrew. * * @author Hadar Porat * @package Numbers_Words */ /** * Include needed files */ require_once "Numbers/Words.php"; /** * Class for translating numbers into Hebrew. * * @category Numbers * @package Numbers_Words * @author Hadar Porat * @license PHP 3.01 http://www.php.net/license/3_01.txt * @link http://pear.php.net/package/Numbers_Words */ class Numbers_Words_he extends Numbers_Words { // {{{ properties /** * Locale name * @var string * @access public */ var $locale = 'he'; /** * Language name in English * @var string * @access public */ var $lang = 'Hebrew'; /** * Native language name * @var string * @access public */ var $lang_native = 'עברית'; /** * The word for the minus sign * @var string * @access private */ var $_minus = 'minus'; // minus sign /** * The sufixes for exponents (singular and plural) * Names partly based on: * http://home.earthlink.net/~mrob/pub/math/largenum.html * http://mathforum.org/dr.math/faq/faq.large.numbers.html * http://www.mazes.com/AmericanNumberingSystem.html * @var array * @access private */ var $_exponent = array( 0 => array(''), 3 => array('×לפי×'), 6 => array('מיליון'), 9 => array('ביליון'), 12 => array('טריליון'), 15 => array('קוודריליון'), 18 => array('קווינטיליון'), 21 => array('sextillion'), 24 => array('septillion'), 27 => array('octillion'), 30 => array('nonillion'), 33 => array('decillion'), 36 => array('undecillion'), 39 => array('duodecillion'), 42 => array('tredecillion'), 45 => array('quattuordecillion'), 48 => array('quindecillion'), 51 => array('sexdecillion'), 54 => array('septendecillion'), 57 => array('octodecillion'), 60 => array('novemdecillion'), 63 => array('vigintillion'), 66 => array('unvigintillion'), 69 => array('duovigintillion'), 72 => array('trevigintillion'), 75 => array('quattuorvigintillion'), 78 => array('quinvigintillion'), 81 => array('sexvigintillion'), 84 => array('septenvigintillion'), 87 => array('octovigintillion'), 90 => array('novemvigintillion'), 93 => array('trigintillion'), 96 => array('untrigintillion'), 99 => array('duotrigintillion'), // 100 => array('googol') - not latin name // 10^googol = 1 googolplex 102 => array('trestrigintillion'), 105 => array('quattuortrigintillion'), 108 => array('quintrigintillion'), 111 => array('sextrigintillion'), 114 => array('septentrigintillion'), 117 => array('octotrigintillion'), 120 => array('novemtrigintillion'), 123 => array('quadragintillion'), 126 => array('unquadragintillion'), 129 => array('duoquadragintillion'), 132 => array('trequadragintillion'), 135 => array('quattuorquadragintillion'), 138 => array('quinquadragintillion'), 141 => array('sexquadragintillion'), 144 => array('septenquadragintillion'), 147 => array('octoquadragintillion'), 150 => array('novemquadragintillion'), 153 => array('quinquagintillion'), 156 => array('unquinquagintillion'), 159 => array('duoquinquagintillion'), 162 => array('trequinquagintillion'), 165 => array('quattuorquinquagintillion'), 168 => array('quinquinquagintillion'), 171 => array('sexquinquagintillion'), 174 => array('septenquinquagintillion'), 177 => array('octoquinquagintillion'), 180 => array('novemquinquagintillion'), 183 => array('sexagintillion'), 186 => array('unsexagintillion'), 189 => array('duosexagintillion'), 192 => array('tresexagintillion'), 195 => array('quattuorsexagintillion'), 198 => array('quinsexagintillion'), 201 => array('sexsexagintillion'), 204 => array('septensexagintillion'), 207 => array('octosexagintillion'), 210 => array('novemsexagintillion'), 213 => array('septuagintillion'), 216 => array('unseptuagintillion'), 219 => array('duoseptuagintillion'), 222 => array('treseptuagintillion'), 225 => array('quattuorseptuagintillion'), 228 => array('quinseptuagintillion'), 231 => array('sexseptuagintillion'), 234 => array('septenseptuagintillion'), 237 => array('octoseptuagintillion'), 240 => array('novemseptuagintillion'), 243 => array('octogintillion'), 246 => array('unoctogintillion'), 249 => array('duooctogintillion'), 252 => array('treoctogintillion'), 255 => array('quattuoroctogintillion'), 258 => array('quinoctogintillion'), 261 => array('sexoctogintillion'), 264 => array('septoctogintillion'), 267 => array('octooctogintillion'), 270 => array('novemoctogintillion'), 273 => array('nonagintillion'), 276 => array('unnonagintillion'), 279 => array('duononagintillion'), 282 => array('trenonagintillion'), 285 => array('quattuornonagintillion'), 288 => array('quinnonagintillion'), 291 => array('sexnonagintillion'), 294 => array('septennonagintillion'), 297 => array('octononagintillion'), 300 => array('novemnonagintillion'), 303 => array('centillion'), 309 => array('duocentillion'), 312 => array('trecentillion'), 366 => array('primo-vigesimo-centillion'), 402 => array('trestrigintacentillion'), 603 => array('ducentillion'), 624 => array('septenducentillion'), // bug on a earthlink page: 903 => array('trecentillion'), 2421 => array('sexoctingentillion'), 3003 => array('millillion'), 3000003 => array('milli-millillion') ); /** * The array containing the digits (indexed by the digits themselves). * @var array * @access private */ var $_digits = array( 0 => '×פס', '×חד', 'שניי×', 'שלושה', '×רבעה', 'חמישה', 'שישה', 'שבעה', 'שמונה', 'תשעה' ); var $_digits_ten = array( 2 => 'עשרי×', 'שלושי×', '×רבעי×', 'חמישי×', 'שישי×', 'שבעי×', 'שמוני×', 'תשעי×' ); var $_digits_female = array( 0 => '×פס', '×חת', 'שתיי×', 'שלוש', '×רבע', 'חמש', 'שש', 'שבע', 'שמונה', 'תשע' ); var $digits_hundreds = array( 0 => '', 'מ××”', 'שני-מ×ות', 'שלוש-מ×ות', '×רבע-מ×ות', 'חמש-מ×ות', 'שש-מ×ות', 'שבע-מ×ות', 'שמונה-מ×ות', 'תשע-מ×ות' ); /** * The word separator * @var string * @access private */ var $_sep = ' '; var $_sep_hundred = '-'; var $_sep_ten = ' ו'; /** * The currency names (based on the below links, * informations from central bank websites and on encyclopedias) * * @var array * @link http://30-03-67.dreamstation.com/currency_alfa.htm World Currency Information * @link http://www.jhall.demon.co.uk/currency/by_abbrev.html World currencies * @link http://www.shoestring.co.kr/world/p.visa/change.htm Currency names in English * @access private */ var $_currency_names = array( 'ALL' => array(array('lek'), array('qindarka')), 'AUD' => array(array('Australian dollar'), array('cent')), 'BAM' => array(array('convertible marka'), array('fenig')), 'BGN' => array(array('lev'), array('stotinka')), 'BRL' => array(array('real'), array('centavos')), 'BYR' => array(array('Belarussian rouble'), array('kopiejka')), 'CAD' => array(array('Canadian dollar'), array('cent')), 'CHF' => array(array('Swiss franc'), array('rapp')), 'CYP' => array(array('Cypriot pound'), array('cent')), 'CZK' => array(array('Czech koruna'), array('halerz')), 'DKK' => array(array('Danish krone'), array('ore')), 'EEK' => array(array('kroon'), array('senti')), 'EUR' => array(array('euro'), array('euro-cent')), 'GBP' => array(array('pound', 'pounds'), array('pence', 'pence')), 'HKD' => array(array('Hong Kong dollar'), array('cent')), 'HRK' => array(array('Croatian kuna'), array('lipa')), 'HUF' => array(array('forint'), array('filler')), 'ILS' => array(array('new sheqel','new sheqels'), array('agora','agorot')), 'ISK' => array(array('Icelandic kr�na'), array('aurar')), 'JPY' => array(array('yen'), array('sen')), 'LTL' => array(array('litas'), array('cent')), 'LVL' => array(array('lat'), array('sentim')), 'MKD' => array(array('Macedonian dinar'), array('deni')), 'MTL' => array(array('Maltese lira'), array('centym')), 'NIS' => array(array('×©×§×œ×™× ×—×“×©×™×'), array('nis')), // need more info if NIS or ILS 'NOK' => array(array('Norwegian krone'), array('oere')), 'PLN' => array(array('zloty', 'zlotys'), array('grosz')), 'ROL' => array(array('Romanian leu'), array('bani')), 'RUB' => array(array('Russian Federation rouble'), array('kopiejka')), 'SEK' => array(array('Swedish krona'), array('oere')), 'SIT' => array(array('Tolar'), array('stotinia')), 'SKK' => array(array('Slovak koruna'), array()), 'TRL' => array(array('lira'), array('kuru�')), 'UAH' => array(array('hryvna'), array('cent')), 'USD' => array(array('dollar'), array('cent')), 'YUM' => array(array('dinars'), array('para')), 'ZAR' => array(array('rand'), array('cent')) ); /** * The default currency name * @var string * @access public */ var $def_currency = 'NIS'; // }}} // {{{ _toWords() /** * Converts a number to its word representation * * @param integer $num An integer between -infinity and infinity inclusive :) * that need to be converted to words * @param integer $power The power of ten for the rest of the number to the right. * Optional, defaults to 0. * @param integer $powsuffix The power name to be added to the end of the return string. * Used internally. Optional, defaults to ''. * * @return string The corresponding word representation * * @access protected * @author Piotr Klaban * @since Numbers_Words 0.16.3 */ function _toWords($num, $power = 0, $powsuffix = '') { $ret = ''; // add a minus sign if (substr($num, 0, 1) == '-') { $ret = $this->_sep . $this->_minus; $num = substr($num, 1); } // strip excessive zero signs and spaces $num = trim($num); $num = preg_replace('/^0+/', '', $num); if (strlen($num) > 3) { $maxp = strlen($num)-1; $curp = $maxp; for ($p = $maxp; $p > 0; --$p) { // power // check for highest power if (isset($this->_exponent[$p])) { // send substr from $curp to $p $snum = substr($num, $maxp - $curp, $curp - $p + 1); $snum = preg_replace('/^0+/', '', $snum); if ($snum !== '') { $cursuffix = $this->_exponent[$power][count($this->_exponent[$power])-1]; if ($powsuffix != '') { $cursuffix .= $this->_sep . $powsuffix; } $ret .= $this->_toWords($snum, $p, $cursuffix); } $curp = $p - 1; continue; } } $num = substr($num, $maxp - $curp, $curp - $p + 1); if ($num == 0) { return $ret; } } elseif ($num == 0 || $num == '') { return $this->_sep . $this->_digits[0]; } $h = $t = $d = 0; switch(strlen($num)) { case 3: $h = (int)substr($num, -3, 1); case 2: $t = (int)substr($num, -2, 1); case 1: $d = (int)substr($num, -1, 1); break; case 0: return; break; } if ($h) { $ret .= $this->_sep . $this->digits_hundreds[$h]; // in English only - add ' and' for [1-9]01..[1-9]99 // (also for 1001..1099, 10001..10099 but it is harder) // for now it is switched off, maybe some language purists // can force me to enable it, or to remove it completely // if (($t + $d) > 0) // $ret .= $this->_sep . 'and'; } // ten, twenty etc. switch ($t) { case 9: case 8: case 7: case 6: case 5: case 4: case 3: case 2: $ret .= $this->_sep . $this->_digits_ten[$t]; break; case 1: switch ($d) { case 0: $ret .= $this->_sep . 'עשר'; break; case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: $ret .= $this->_sep . $this->_digits[$d] . '-עשר'; break; } break; } if ($t != 1 && $d > 0) { // add digits only in <0>,<1,9> and <21,inf> // add minus sign between [2-9] and digit if ($t > 1) { $ret .= $this -> _sep_ten . $this->_digits[$d]; } else { if (strlen($ret)>0) { $ret .= $this->_sep . 'ו' . $this->_digits[$d]; } else { $ret .= $this->_sep . $this->_digits[$d]; } } } if ($power > 0) { if (isset($this->_exponent[$power])) { $lev = $this->_exponent[$power]; } if (!isset($lev) || !is_array($lev)) { return null; } $ret .= $this->_sep . $lev[0]; } if ($powsuffix != '') { $ret .= $this->_sep . $powsuffix; } return $ret; } // }}} // {{{ toCurrencyWords() /** * Converts a currency value to its word representation * (with monetary units) * * @param integer $int_curr An international currency symbol * as defined by the ISO 4217 standard (three characters) * @param integer $decimal A money total amount without fraction part (e.g. amount of dollars) * @param integer $fraction Fractional part of the money amount (e.g. amount of cents) * Optional. Defaults to false. * @param integer $convert_fraction Convert fraction to words (left as numeric if set to false). * Optional. Defaults to true. * * @return string The corresponding word representation for the currency * * @access public * @author Piotr Klaban * @since Numbers_Words 0.4 */ function toCurrencyWords($int_curr, $decimal, $fraction = false, $convert_fraction = true) { $int_curr = strtoupper($int_curr); if (!isset($this->_currency_names[$int_curr])) { $int_curr = $this->def_currency; } $curr_names = $this->_currency_names[$int_curr]; $ret = trim($this->_toWords($decimal)); $lev = ($decimal == 1) ? 0 : 1; if ($lev > 0) { if (count($curr_names[0]) > 1) { $ret .= $this->_sep . $curr_names[0][$lev]; } else { $ret .= $this->_sep . $curr_names[0][0] . ''; } } else { $ret .= $this->_sep . $curr_names[0][0]; } if ($fraction !== false) { if ($convert_fraction) { $ret .= $this->_sep . trim($this->_toWords($fraction)); } else { $ret .= $this->_sep . $fraction; } $lev = ($fraction == 1) ? 0 : 1; if ($lev > 0) { if (count($curr_names[1]) > 1) { $ret .= $this->_sep . $curr_names[1][$lev]; } else { $ret .= $this->_sep . $curr_names[1][0] . ''; } } else { $ret .= $this->_sep . $curr_names[1][0]; } } return $ret; } // }}} } Numbers_Words-0.16.4/Numbers/Words/lang.hu_HU.php0000644000076500007650000003272311732225114020246 0ustar igorigor array(''), 3 => array('ezer'), 6 => array('millió'), 9 => array('milliárd'), 12 => array('billió'), 15 => array('billiárd'), 18 => array('trillió'), 21 => array('trilliárd'), 24 => array('kvadrillió'), 27 => array('kvadrilliárd'), 30 => array('kvintillió'), 33 => array('kvintilliárd'), 36 => array('szextillió'), 39 => array('szextilliárd'), 42 => array('szeptillió'), 45 => array('szeptilliárd'), 48 => array('oktillió'), 51 => array('oktilliárd'), 54 => array('nonillió'), 57 => array('nonilliárd'), 60 => array('decillió'), 63 => array('decilliárd'), 600 => array('centillió') ); /** * The array containing the digits (indexed by the digits themselves). * @var array * @access private */ var $_digits = array( 0 => 'nulla', 'egy', 'kettõ', 'három', 'négy', 'öt', 'hat', 'hét', 'nyolc', 'kilenc' ); /** * The word separator * @var string * @access private */ var $_sep = ''; /** * The thousands word separator * @var string * @access private */ var $_thousand_sep = '-'; /** * The currency names (based on the below links, * informations from central bank websites and on encyclopedias) * * @var array * @link http://30-03-67.dreamstation.com/currency_alfa.htm World Currency Information * @link http://www.jhall.demon.co.uk/currency/by_abbrev.html World currencies * @link http://www.shoestring.co.kr/world/p.visa/change.htm Currency names in English * @access private */ var $_currency_names = array( 'ALL' => array(array('lek'), array('qindarka')), 'AUD' => array(array('Australian dollar'), array('cent')), 'BAM' => array(array('convertible marka'), array('fenig')), 'BGN' => array(array('lev'), array('stotinka')), 'BRL' => array(array('real'), array('centavos')), 'BYR' => array(array('Belarussian rouble'), array('kopiejka')), 'CAD' => array(array('Canadian dollar'), array('cent')), 'CHF' => array(array('Swiss franc'), array('rapp')), 'CYP' => array(array('Cypriot pound'), array('cent')), 'CZK' => array(array('Czech koruna'), array('halerz')), 'DKK' => array(array('Danish krone'), array('ore')), 'EEK' => array(array('kroon'), array('senti')), 'EUR' => array(array('euro'), array('euro-cent')), 'GBP' => array(array('pound', 'pounds'), array('pence', 'pence')), 'HKD' => array(array('Hong Kong dollar'), array('cent')), 'HRK' => array(array('Croatian kuna'), array('lipa')), 'HUF' => array(array('forint'), array('filler')), 'ILS' => array(array('new sheqel','new sheqels'), array('agora','agorot')), 'ISK' => array(array('Icelandic króna'), array('aurar')), 'JPY' => array(array('yen'), array('sen')), 'LTL' => array(array('litas'), array('cent')), 'LVL' => array(array('lat'), array('sentim')), 'MKD' => array(array('Macedonian dinar'), array('deni')), 'MTL' => array(array('Maltese lira'), array('centym')), 'NOK' => array(array('Norwegian krone'), array('oere')), 'PLN' => array(array('zloty', 'zlotys'), array('grosz')), 'ROL' => array(array('Romanian leu'), array('bani')), 'RUB' => array(array('Russian Federation rouble'), array('kopiejka')), 'SEK' => array(array('Swedish krona'), array('oere')), 'SIT' => array(array('Tolar'), array('stotinia')), 'SKK' => array(array('Slovak koruna'), array()), 'TRL' => array(array('lira'), array('kuruþ')), 'UAH' => array(array('hryvna'), array('cent')), 'USD' => array(array('dollar'), array('cent')), 'YUM' => array(array('dinars'), array('para')), 'ZAR' => array(array('rand'), array('cent')) ); /** * The default currency name * @var string * @access public */ var $def_currency = 'HUF'; // forint // }}} // {{{ _toWords() /** * Converts a number to its word representation * in the Hungarian language * * @param integer $num An integer between -infinity and infinity inclusive :) * that need to be converted to words * @param integer $power The power of ten for the rest of the number to the right. * Optional, defaults to 0. * @param integer $powsuffix The power name to be added to the end of the return string. * Used internally. Optional, defaults to ''. * * @return string The corresponding word representation * * @access protected * @author Nils Homp * @since Numbers_Words 0.16.3 */ function _toWords($num, $options = array(), $power = 0, $powsuffix = '', $gt2000 = false) { $chk_gt2000 = true; /** * Loads user options */ extract($options, EXTR_IF_EXISTS); /** * Return string */ $ret = ''; // add a minus sign if (substr($num, 0, 1) == '-') { $ret = $this->_sep . $this->_minus; $num = substr($num, 1); } // strip excessive zero signs and spaces $num = trim($num); $num = preg_replace('/^0+/', '', $num); if ($chk_gt2000) $gt2000 = $num > 2000; if (strlen($num) > 3) { $maxp = strlen($num)-1; $curp = $maxp; for ($p = $maxp; $p > 0; --$p) { // power // check for highest power if (isset($this->_exponent[$p])) { // send substr from $curp to $p $snum = substr($num, $maxp - $curp, $curp - $p + 1); $snum = preg_replace('/^0+/', '', $snum); if ($snum !== '') { $cursuffix = $this->_exponent[$power][count($this->_exponent[$power])-1]; if ($powsuffix != '') { $cursuffix .= $this->_sep . $powsuffix; } $ret .= $this->_toWords( $snum, array('chk_gt2000' => false), $p, $cursuffix, $gt2000 ); if ($gt2000) $ret .= $this->_thousand_sep; } $curp = $p - 1; continue; } } $num = substr($num, $maxp - $curp, $curp - $p + 1); if ($num == 0) { return rtrim($ret, $this->_thousand_sep); } } elseif ($num == 0 || $num == '') { return $this->_sep . $this->_digits[0]; } $h = $t = $d = 0; switch(strlen($num)) { case 3: $h = (int)substr($num, -3, 1); case 2: $t = (int)substr($num, -2, 1); case 1: $d = (int)substr($num, -1, 1); break; case 0: return; break; } if ($h) { $ret .= $this->_sep . $this->_digits[$h] . $this->_sep . 'száz'; } // ten, twenty etc. switch ($t) { case 9: case 5: $ret .= $this->_sep . $this->_digits[$t] . 'ven'; break; case 8: case 6: $ret .= $this->_sep . $this->_digits[$t] . 'van'; break; case 7: $ret .= $this->_sep . 'hetven'; break; case 3: $ret .= $this->_sep . 'harminc'; break; case 4: $ret .= $this->_sep . 'negyven'; break; case 2: switch ($d) { case 0: $ret .= $this->_sep . 'húsz'; break; case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: $ret .= $this->_sep . 'húszon'; break; } break; case 1: switch ($d) { case 0: $ret .= $this->_sep . 'tíz'; break; case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: $ret .= $this->_sep . 'tizen'; break; } break; } if ($d > 0) { // add digits only in <0> and <1,inf) $ret .= $this->_sep . $this->_digits[$d]; } if ($power > 0) { if (isset($this->_exponent[$power])) { $lev = $this->_exponent[$power]; } if (!isset($lev) || !is_array($lev)) { return null; } $ret .= $this->_sep . $lev[0]; } if ($powsuffix != '') { $ret .= $this->_sep . $powsuffix; } return $ret; } // }}} // {{{ toCurrencyWords() /** * Converts a currency value to its word representation * (with monetary units) in English language * * @param integer $int_curr An international currency symbol * as defined by the ISO 4217 standard (three characters) * @param integer $decimal A money total amount without fraction part (e.g. amount of dollars) * @param integer $fraction Fractional part of the money amount (e.g. amount of cents) * Optional. Defaults to false. * @param integer $convert_fraction Convert fraction to words (left as numeric if set to false). * Optional. Defaults to true. * * @return string The corresponding word representation for the currency * * @access public * @author Piotr Klaban * @since Numbers_Words 0.4 */ function toCurrencyWords($int_curr, $decimal, $fraction = false, $convert_fraction = true) { $int_curr = strtoupper($int_curr); if (!isset($this->_currency_names[$int_curr])) { $int_curr = $this->def_currency; } $curr_names = $this->_currency_names[$int_curr]; $ret = trim($this->_toWords($decimal)); $lev = ($decimal == 1) ? 0 : 1; if ($lev > 0) { if (count($curr_names[0]) > 1) { $ret .= $this->_sep . $curr_names[0][$lev]; } else { $ret .= $this->_sep . $curr_names[0][0] . 's'; } } else { $ret .= $this->_sep . $curr_names[0][0]; } if ($fraction !== false) { if ($convert_fraction) { $ret .= $this->_sep . trim($this->_toWords($fraction)); } else { $ret .= $this->_sep . $fraction; } $lev = ($fraction == 1) ? 0 : 1; if ($lev > 0) { if (count($curr_names[1]) > 1) { $ret .= $this->_sep . $curr_names[1][$lev]; } else { $ret .= $this->_sep . $curr_names[1][0] . 's'; } } else { $ret .= $this->_sep . $curr_names[1][0]; } } return $ret; } // }}} } Numbers_Words-0.16.4/Numbers/Words/lang.id.php0000644000076500007650000001766411732225114017641 0ustar igorigor * @author Arif Rifai Dwiyanto * @license PHP 3.01 http://www.php.net/license/3_01.txt * @version SVN: $Id$ * @link http://pear.php.net/package/Numbers_Words */ require_once "PEAR.php"; require_once "Numbers/Words.php"; /** * Class for translating numbers into Indonesian. * * @category Numbers * @package Numbers_Words * @author Ernas M. Jamil * @author Arif Rifai Dwiyanto * @license PHP 3.01 http://www.php.net/license/3_01.txt * @link http://pear.php.net/package/Numbers_Words */ class Numbers_Words_id extends Numbers_Words { // {{{ properties /** * Locale name * @var string * @access public */ var $locale = 'id'; /** * Language name in English * @var string * @access public */ var $lang = 'Indonesia Language'; /** * Native language name * @var string * @access public */ var $lang_native = 'Bahasa Indonesia'; /** * The word for the minus sign * @var string * @access private */ var $_minus = 'minus'; // minus sign /** * The sufixes for exponents (singular and plural) * Names partly based on: * http://www.users.dircon.co.uk/~shaunf/shaun/numbers/millions.htm * @var array * @access private */ var $_exponent = array( 0 => array(''), 3 => array('ribu'), 6 => array('juta'), 9 => array('milyar'), 12 => array('trilyun'), 24 => array('quadrillion'), 30 => array('quintillion'), 36 => array('sextillion'), 42 => array('septillion'), 48 => array('octillion'), 54 => array('nonillion'), 60 => array('decillion'), 66 => array('undecillion'), 72 => array('duodecillion'), 78 => array('tredecillion'), 84 => array('quattuordecillion'), 90 => array('quindecillion'), 96 => array('sexdecillion'), 102 => array('septendecillion'), 108 => array('octodecillion'), 114 => array('novemdecillion'), 120 => array('vigintillion'), 192 => array('duotrigintillion'), 600 => array('centillion') ); /** * The array containing the digits (indexed by the digits themselves). * @var array * @access private */ var $_digits = array( 0 => 'nol', 'satu', 'dua', 'tiga', 'empat', 'lima', 'enam', 'tujuh', 'delapan', 'sembilan' ); /** * The word separator * @var string * @access private */ var $_sep = ' '; // }}} // {{{ _toWords() /** * Converts a number to its word representation * in Indonesian language * * @param integer $num An integer between -infinity and infinity inclusive :) * that need to be converted to words * @param integer $power The power of ten for the rest of the number to the right. * Optional, defaults to 0. * @param integer $powsuffix The power name to be added to the end of the return string. * Used internally. Optional, defaults to ''. * * @return string The corresponding word representation * * @access protected * @author Ernas M. Jamil * @since Numbers_Words 0.16.3 */ function _toWords($num, $power = 0, $powsuffix = '') { $ret = ''; // add a minus sign if (substr($num, 0, 1) == '-') { $ret = $this->_sep . $this->_minus; $num = substr($num, 1); } // strip excessive zero signs and spaces $num = trim($num); $num = preg_replace('/^0+/', '', $num); if (strlen($num) > 4) { $maxp = strlen($num)-1; $curp = $maxp; for ($p = $maxp; $p > 0; --$p) { // power // check for highest power if (isset($this->_exponent[$p])) { // send substr from $curp to $p $snum = substr($num, $maxp - $curp, $curp - $p + 1); $snum = preg_replace('/^0+/', '', $snum); if ($snum !== '') { $cursuffix = $this->_exponent[$power][count($this->_exponent[$power])-1]; if ($powsuffix != '') { $cursuffix .= $this->_sep . $powsuffix; } $ret .= $this->_toWords($snum, $p, $cursuffix); } $curp = $p - 1; continue; } } $num = substr($num, $maxp - $curp, $curp - $p + 1); if ($num == 0) { return $ret; } } elseif ($num == 0 || $num == '') { return $this->_sep . $this->_digits[0]; } $h = $t = $d = $th = 0; switch (strlen($num)) { case 4: $th = (int)substr($num, -4, 1); case 3: $h = (int)substr($num, -3, 1); case 2: $t = (int)substr($num, -2, 1); case 1: $d = (int)substr($num, -1, 1); break; case 0: return; break; } if ($th) { if ($th==1) { $ret .= $this->_sep . 'seribu'; } else { $ret .= $this->_sep . $this->_digits[$th] . $this->_sep . 'ribu'; } } if ($h) { if ($h==1) { $ret .= $this->_sep . 'seratus'; } else { $ret .= $this->_sep . $this->_digits[$h] . $this->_sep . 'ratus'; } // in English only - add ' and' for [1-9]01..[1-9]99 // (also for 1001..1099, 10001..10099 but it is harder) // for now it is switched off, maybe some language purists // can force me to enable it, or to remove it completely // if (($t + $d) > 0) } // ten, twenty etc. switch ($t) { case 9: case 8: case 7: case 6: case 5: case 4: case 3: case 2: $ret .= $this->_sep . $this->_digits[$t] . ' puluh'; break; case 1: switch ($d) { case 0: $ret .= $this->_sep . 'sepuluh'; break; case 1: $ret .= $this->_sep . 'sebelas'; break; case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: $ret .= $this->_sep . $this->_digits[$d] . ' belas'; break; } break; } if ($t != 1 && $d > 0) { // add digits only in <0>,<1,9> and <21,inf> // add minus sign between [2-9] and digit if ($t > 1) { $ret .= ' ' . $this->_digits[$d]; } else { $ret .= $this->_sep . $this->_digits[$d]; } } if ($power > 0) { if (isset($this->_exponent[$power])) { $lev = $this->_exponent[$power]; } if (!isset($lev) || !is_array($lev)) { return null; } $ret .= $this->_sep . $lev[0]; } if ($powsuffix != '') { $ret .= $this->_sep . $powsuffix; } return $ret; } // }}} } Numbers_Words-0.16.4/Numbers/Words/lang.it_IT.php0000644000076500007650000002465111732225114020247 0ustar igorigor * @author Davide Caironi * @license PHP 3.01 http://www.php.net/license/3_01.txt * @version SVN: $Id$ * @link http://pear.php.net/package/Numbers_Words */ /** * Class for translating numbers into Italian. * * @author Filippo Beltramini * @author Davide Caironi * @package Numbers_Words */ /** * Include needed files */ require_once "Numbers/Words.php"; /** * Class for translating numbers into Italian. * It supports up to quadrilions * * @category Numbers * @package Numbers_Words * @author Filippo Beltramini * @author Davide Caironi * @license PHP 3.01 http://www.php.net/license/3_01.txt * @link http://pear.php.net/package/Numbers_Words */ class Numbers_Words_it_IT extends Numbers_Words { // {{{ properties /** * Locale name * @var string * @access public */ var $locale = 'it_IT'; /** * Language name in English * @var string * @access public */ var $lang = 'Italian'; /** * Native language name * @var string * @access public */ var $lang_native = 'Italiano'; /** * The word for the minus sign * @var string * @access private */ var $_minus = 'meno '; /** * The sufixes for exponents (singular and plural) * @var array * @access private */ var $_exponent = array( 0 => array('',''), 3 => array('mille','mila'), 6 => array('milione','miloni'), 12 => array('miliardo','miliardi'), 18 => array('trillone','trilloni'), 24 => array('quadrilione','quadrilioni'), ); /** * The array containing the digits (indexed by the digits themselves). * @var array * @access private */ var $_digits = array( 0 => 'zero', 'uno', 'due', 'tre', 'quattro', 'cinque', 'sei', 'sette', 'otto', 'nove' ); /** * The word separator * @var string * @access private */ var $_sep = ''; // }}} // {{{ _toWords() /** * Converts a number to its word representation * in italiano. * * @param integer $num An integer between -infinity and infinity inclusive :) * that should be converted to a words representation * @param integer $power The power of ten for the rest of the number to the right. * For example toWords(12,3) should give "doce mil". * Optional, defaults to 0. * * @return string The corresponding word representation * * @access protected * @author Filippo Beltramini * @since Numbers_Words 0.16.3 */ function _toWords($num, $power = 0) { // The return string; $ret = ''; // add a the word for the minus sign if necessary if (substr($num, 0, 1) == '-') { $ret = $this->_sep . $this->_minus; $num = substr($num, 1); } // strip excessive zero signs $num = preg_replace('/^0+/', '', $num); if (strlen($num) > 6) { $current_power = 6; // check for highest power if (isset($this->_exponent[$power])) { // convert the number above the first 6 digits // with it's corresponding $power. $snum = substr($num, 0, -6); $snum = preg_replace('/^0+/', '', $snum); if ($snum !== '') { $ret .= $this->_toWords($snum, $power + 6); } } $num = substr($num, -6); if ($num == 0) { return $ret; } } elseif ($num == 0 || $num == '') { return(' '.$this->_digits[0].' '); $current_power = strlen($num); } else { $current_power = strlen($num); } // See if we need "thousands" $thousands = floor($num / 1000); if ($thousands == 1) { $ret .= $this->_sep . 'mille' . $this->_sep; } elseif ($thousands > 1) { $ret .= $this->_toWords($thousands, 3) . $this->_sep;//. 'mil' . $this->_sep; } // values for digits, tens and hundreds $h = floor(($num / 100) % 10); $t = floor(($num / 10) % 10); $d = floor($num % 10); // centinaia: duecento, trecento, etc... switch ($h) { case 1: if (($d == 0) and ($t == 0)) { // is it's '100' use 'cien' $ret .= $this->_sep . 'cento'; } else { $ret .= $this->_sep . 'cento'; } break; case 2: case 3: case 4: case 6: case 8: $ret .= $this->_sep . $this->_digits[$h] . 'cento'; break; case 5: $ret .= $this->_sep . 'cinquecento'; break; case 7: $ret .= $this->_sep . 'settecento'; break; case 9: $ret .= $this->_sep . 'novecento'; break; } // decine: venti trenta, etc... switch ($t) { case 9: switch ($d){ case 1: case 8: $ret .= $this->_sep . 'novant' ; break; default: $ret .= $this->_sep . 'novanta' ; break; } break; case 8: switch ($d){ case 1: case 8: $ret .= $this->_sep . 'ottant' ; break; default: $ret .= $this->_sep . 'ottanta' ; break; } break; case 7: switch ($d){ case 1: case 8: $ret .= $this->_sep . 'settant' ; break; default: $ret .= $this->_sep . 'settanta' ; break; } break; case 6: switch ($d){ case 1: case 8: $ret .= $this->_sep . 'sessant' ; break; default: $ret .= $this->_sep . 'sessanta' ; break; } break; case 5: switch ($d){ case 1: case 8: $ret .= $this->_sep . 'cinquant' ; break; default: $ret .= $this->_sep . 'cinquanta' ; break; } break; case 4: switch ($d){ case 1: case 8: $ret .= $this->_sep . 'quarant' ; break; default: $ret .= $this->_sep . 'quaranta' ; break; } break; case 3: switch ($d){ case 1: case 8: $ret .= $this->_sep . 'trent' ; break; default: $ret .= $this->_sep . 'trenta' ; break; } break; case 2: switch ($d){ case 0: $ret .= $this->_sep . 'venti'; break; case 1: case 8: $ret .= $this->_sep . 'vent' . $this->_digits[$d]; break; default: $ret .= $this->_sep . 'venti' . $this->_digits[$d]; break; } break; case 1: switch ($d) { case 0: $ret .= $this->_sep . 'dieci'; break; case 1: $ret .= $this->_sep . 'undici'; break; case 2: $ret .= $this->_sep . 'dodici'; break; case 3: $ret .= $this->_sep . 'tredici'; break; case 4: $ret .= $this->_sep . 'quattordici'; break; case 5: $ret .= $this->_sep . 'quindici'; break; case 6: $ret .= $this->_sep . 'sedici'; break; case 7: $ret .= $this->_sep . 'diciassette'; break; case 8: $ret .= $this->_sep . 'diciotto'; break; case 9: $ret .= $this->_sep . 'diciannove'; break; } break; } // add digits only if it is a multiple of 10 and not 1x or 2x if (($t != 1) and ($t != 2) and ($d > 0)) { // don't add 'e' for numbers below 10 if ($t != 0) { // use 'un' instead of 'uno' when there is a suffix ('mila', 'milloni', etc...) if (($power > 0) and ($d == 1)) { $ret .= $this->_sep.' e un'; } else { $ret .= $this->_sep.''.$this->_digits[$d]; } } else { if (($power > 0) and ($d == 1)) { $ret .= $this->_sep.'un '; } else { $ret .= $this->_sep.$this->_digits[$d]; } } } if ($power > 0) { if (isset($this->_exponent[$power])) { $lev = $this->_exponent[$power]; } if (!isset($lev) || !is_array($lev)) { return null; } // if it's only one use the singular suffix if (($d == 1) and ($t == 0) and ($h == 0)) { $suffix = $lev[0]; } else { $suffix = $lev[1]; } if ($num != 0) { $ret .= $this->_sep . $suffix; } } return $ret; } // }}} } Numbers_Words-0.16.4/Numbers/Words/lang.lt.php0000644000076500007650000002014311732225114017646 0ustar igorigor * @license PHP 3.01 http://www.php.net/license/3_01.txt * @version SVN: $Id$ * @link http://pear.php.net/package/Numbers_Words */ /** * Class for translating numbers into Lithuanian. * * @author Laurynas Butkus * @package Numbers_Words */ /** * Include needed files */ require_once "Numbers/Words.php"; /** * Class for translating numbers into Lithuanian. * * @category Numbers * @package Numbers_Words * @author Laurynas Butkus * @license PHP 3.01 http://www.php.net/license/3_01.txt * @link http://pear.php.net/package/Numbers_Words */ class Numbers_Words_lt extends Numbers_Words { // {{{ properties /** * Locale name * @var string * @access public */ var $locale = 'lt'; /** * Language name in English * @var string * @access public */ var $lang = 'Lithuanian'; /** * Native language name * @var string * @access public */ var $lang_native = 'lietuviðkai'; /** * The word for the minus sign * @var string * @access private */ var $_minus = 'minus'; // minus sign /** * The sufixes for exponents (singular and plural) * @var array * @access private */ var $_exponent = array( 0 => array(''), 3 => array('tûkstantis','tûkstanèiai','tûkstanèiø'), 6 => array('milijonas','milijonai','milijonø'), 9 => array('bilijonas','bilijonai','bilijonø'), 12 => array('trilijonas','trilijonai','trilijonø'), 15 => array('kvadrilijonas','kvadrilijonai','kvadrilijonø'), 18 => array('kvintilijonas','kvintilijonai','kvintilijonø') ); /** * The array containing the digits (indexed by the digits themselves). * @var array * @access private */ var $_digits = array( 0 => 'nulis', 'vienas', 'du', 'trys', 'keturi', 'penki', 'ðeði', 'septyni', 'aðtuoni', 'devyni' ); /** * The word separator * @var string * @access private */ var $_sep = ' '; /** * The default currency name * @var string * @access public */ var $def_currency = 'LTL'; // }}} // {{{ _toWords() /** * Converts a number to its word representation * in Lithuanian language * * @param integer $num An integer between -infinity and infinity inclusive :) * that need to be converted to words * @param integer $power The power of ten for the rest of the number to the right. * Optional, defaults to 0. * @param integer $powsuffix The power name to be added to the end of the return string. * Used internally. Optional, defaults to ''. * * @return string The corresponding word representation * * @access protected * @author Laurynas Butkus * @since Numbers_Words 0.16.3 */ function _toWords($num, $power = 0, $powsuffix = '') { $ret = ''; // add a minus sign if (substr($num, 0, 1) == '-') { $ret = $this->_sep . $this->_minus; $num = substr($num, 1); } // strip excessive zero signs and spaces $num = trim($num); $num = preg_replace('/^0+/', '', $num); if (strlen($num) > 3) { $maxp = strlen($num)-1; $curp = $maxp; for ($p = $maxp; $p > 0; --$p) { // power // check for highest power if (isset($this->_exponent[$p])) { // send substr from $curp to $p $snum = substr($num, $maxp - $curp, $curp - $p + 1); $snum = preg_replace('/^0+/', '', $snum); if ($snum !== '') { $cursuffix = $this->_exponent[$power][count($this->_exponent[$power])-1]; if ($powsuffix != '') { $cursuffix .= $this->_sep . $powsuffix; } $ret .= $this->_toWords($snum, $p, $cursuffix); } $curp = $p - 1; continue; } } $num = substr($num, $maxp - $curp, $curp - $p + 1); if ($num == 0) { return $ret; } } elseif ($num == 0 || $num == '') { return $this->_sep . $this->_digits[0]; } $h = $t = $d = 0; switch(strlen($num)) { case 3: $h = (int)substr($num, -3, 1); case 2: $t = (int)substr($num, -2, 1); case 1: $d = (int)substr($num, -1, 1); break; case 0: return; break; } if ( $h > 1 ) { $ret .= $this->_sep . $this->_digits[$h] . $this->_sep . 'ðimtai'; } elseif ( $h ) { $ret .= $this->_sep . 'ðimtas'; } // ten, twenty etc. switch ($t) { case 9: $ret .= $this->_sep . 'devyniasdeðimt'; break; case 8: $ret .= $this->_sep . 'aðtuoniasdeðimt'; break; case 7: $ret .= $this->_sep . 'septyniasdeðimt'; break; case 6: $ret .= $this->_sep . 'ðeðiasdeðimt'; break; case 5: $ret .= $this->_sep . 'penkiasdeðimt'; break; case 4: $ret .= $this->_sep . 'keturiasdeðimt'; break; case 3: $ret .= $this->_sep . 'trisdeðimt'; break; case 2: $ret .= $this->_sep . 'dvideðimt'; break; case 1: switch ($d) { case 0: $ret .= $this->_sep . 'deðimt'; break; case 1: $ret .= $this->_sep . 'vienuolika'; break; case 2: $ret .= $this->_sep . 'dvylika'; break; case 3: $ret .= $this->_sep . 'trylika'; break; case 4: $ret .= $this->_sep . 'keturiolika'; break; case 5: $ret .= $this->_sep . 'penkiolika'; break; case 6: $ret .= $this->_sep . 'ðeðiolika'; break; case 7: $ret .= $this->_sep . 'septyniolika'; break; case 8: $ret .= $this->_sep . 'aðtuoniolika'; break; case 9: $ret .= $this->_sep . 'devyniolika'; break; } break; } // add digits only in <0>,<1,9> and <21,inf> if ($t != 1 && $d > 0) { if ( $d > 1 || !$power || $t ) { $ret .= $this->_sep . $this->_digits[$d]; } } if ($power > 0) { if (isset($this->_exponent[$power])) { $lev = $this->_exponent[$power]; } if (!isset($lev) || !is_array($lev)) { return null; } //echo " $t $d
"; if ($t == 1 || ($t > 0 && $d == 0 )) { $ret .= $this->_sep . $lev[2]; } elseif ( $d > 1 ) { $ret .= $this->_sep . $lev[1]; } else { $ret .= $this->_sep . $lev[0]; } } if ($powsuffix != '') { $ret .= $this->_sep . $powsuffix; } return $ret; } // }}} } Numbers_Words-0.16.4/Numbers/Words/lang.nl.php0000644000076500007650000002727611732225114017656 0ustar igorigor * @license PHP 3.01 http://www.php.net/license/3_01.txt * @version SVN: $Id$ * @link http://pear.php.net/package/Numbers_Words */ /** * * Class for translating numbers into Dutch. * @author Piotr Klaban * @author WHAM van Dinter (for Dutch Translations) * @package Numbers_Words */ /** * Include needed files */ require_once "Numbers/Words.php"; /** * Class for translating numbers into Dutch. * * @category Numbers * @package Numbers_Words * @author Piotr Klaban * @author WHAM van Dinter (for Dutch Translations) * @license PHP 3.01 http://www.php.net/license/3_01.txt * @link http://pear.php.net/package/Numbers_Words */ class Numbers_Words_nl extends Numbers_Words { // {{{ properties /** * Locale name * @var string * @access public */ var $locale = 'nl'; /** * Language name in English * @var string * @access public */ var $lang = 'Dutch'; /** * Native language name * @var string * @access public */ var $lang_native = 'Nederlands'; /** * The word for the minus sign * @var string * @access private */ var $_minus = 'Minus'; // minus sign /** * The sufixes for exponents (singular and plural) * Names partly based on: * http://nl.wikipedia.org/wiki/Quadriljoen * @var array * @access private */ var $_exponent = array( 0 => array(''), 3 => array('Duizend','Duizend'), 6 => array('Miljoen','Miljoen'), 9 => array('Miljard','Miljard'), 12 => array('Biljoen','Biljoen'), 15 => array('Biljard','Biljard'), 18 => array('Triljoen','Triljoen'), 21 => array('Triljard','Triljard'), 24 => array('Quadriljoen','Quadriljoen'), 27 => array('Quadriljard','Quadriljard'), 30 => array('Quintiljoen','Quintiljoen'), 33 => array('Quintiljard','Quintiljard'), 36 => array('Sextiljoen','Sextiljoen'), 39 => array('Sextiljard','Sextiljard'), 42 => array('Septiljoen','Septiljoen'), 45 => array('Septiljard','Septiljard'), 48 => array('Octiljoen','Octiljoen'), 51 => array('Octiljard','Octiljard'), 54 => array('Noniljoen','Noniljoen'), 57 => array('Noniljard','Noniljard'), 60 => array('Deciljoen','Deciljoen'), 63 => array('Deciljard','Deciljard'), 66 => array('Undeciljoen','Undeciljoen'), 69 => array('Undeciljard','Undeciljard'), 72 => array('Duodeciljoen','Duodeciljoen'), 75 => array('Duodeciljard','Duodeciljard'), 78 => array('Tredeciljoen','Tredeciljoen'), 81 => array('Tredeciljard','Tredeciljard'), 120 => array('Vigintiljoen','Vigintiljoen'), 123 => array('Vigintiljard','Vigintiljard'), 600 => array('Zentiljoen','Zentiljoen'), // oder Centillion 603 => array('Zentiljardn','Zentiljard') ); /** * The array containing the digits (indexed by the digits themselves). * @var array * @access private */ var $_digits = array( 0 => 'nul', 'een', 'twee', 'drie', 'vier', 'vijf', 'zes', 'zeven', 'acht', 'negen' ); /** * The word separator * @var string * @access private */ var $_sep = ''; /** * The exponent word separator * @var string * @access private */ var $_sep2 = '-'; /** * The currency names (based on the below links, * informations from central bank websites and on encyclopedias) * * @var array * @link http://30-03-67.dreamstation.com/currency_alfa.htm World Currency Information * @link http://www.jhall.demon.co.uk/currency/by_abbrev.html World currencies * @link http://www.shoestring.co.kr/world/p.visa/change.htm Currency names in English * @access private */ var $_currency_names = array( 'ALL' => array(array('lek'), array('qindarka')), 'AUD' => array(array('Australian dollar'), array('cent')), 'BAM' => array(array('convertible marka'), array('fenig')), 'BGN' => array(array('lev'), array('stotinka')), 'BRL' => array(array('real'), array('centavos')), 'BYR' => array(array('Belarussian rouble'), array('kopiejka')), 'CAD' => array(array('Canadian dollar'), array('cent')), 'CHF' => array(array('Swiss franc'), array('rapp')), 'CYP' => array(array('Cypriot pound'), array('cent')), 'CZK' => array(array('Czech koruna'), array('halerz')), 'DKK' => array(array('Danish krone'), array('ore')), 'EEK' => array(array('kroon'), array('senti')), 'EUR' => array(array('euro'), array('euro-cent')), 'GBP' => array(array('pound', 'pounds'), array('pence', 'pence')), 'HKD' => array(array('Hong Kong dollar'), array('cent')), 'HRK' => array(array('Croatian kuna'), array('lipa')), 'HUF' => array(array('forint'), array('filler')), 'ILS' => array(array('new sheqel','new sheqels'), array('agora','agorot')), 'ISK' => array(array('Icelandic kr\F3na'), array('aurar')), 'JPY' => array(array('yen'), array('sen')), 'LTL' => array(array('litas'), array('cent')), 'LVL' => array(array('lat'), array('sentim')), 'MKD' => array(array('Macedonian dinar'), array('deni')), 'MTL' => array(array('Maltese lira'), array('centym')), 'NOK' => array(array('Norwegian krone'), array('oere')), 'PLN' => array(array('zloty', 'zlotys'), array('grosz')), 'ROL' => array(array('Romanian leu'), array('bani')), 'RUB' => array(array('Russian Federation rouble'), array('kopiejka')), 'SEK' => array(array('Swedish krona'), array('oere')), 'SIT' => array(array('Tolar'), array('stotinia')), 'SKK' => array(array('Slovak koruna'), array()), 'TRL' => array(array('lira'), array('kuru\FE')), 'UAH' => array(array('hryvna'), array('cent')), 'USD' => array(array('dollar'), array('cent')), 'YUM' => array(array('dinars'), array('para')), 'ZAR' => array(array('rand'), array('cent')) ); var $def_currency = 'EUR'; // }}} // {{{ _toWords() /** * Converts a number to its word representation * in Dutch language. * * @param integer $num An integer between -infinity and infinity inclusive :) * that need to be converted to words * @param integer $power The power of ten for the rest of the number to the right. * Optional, defaults to 0. * @param integer $powsuffix The power name to be added to the end of the return string. * Used internally. Optional, defaults to ''. * * @return string The corresponding word representation * * @access protected * @author Piotr Klaban * @author WHAM van Dinter * @since Numbers_Words 0.16.3 */ function _toWords($num, $power = 0, $powsuffix = '') { $ret = ''; // add a minus sign if (substr($num, 0, 1) == '-') { $ret = $this->_sep . $this->_minus; $num = substr($num, 1); } // strip excessive zero signs and spaces $num = trim($num); $num = preg_replace('/^0+/', '', $num); if (strlen($num) > 3) { $maxp = strlen($num)-1; $curp = $maxp; for ($p = $maxp; $p > 0; --$p) { // power // check for highest power if (isset($this->_exponent[$p])) { // send substr from $curp to $p $snum = substr($num, $maxp - $curp, $curp - $p + 1); $snum = preg_replace('/^0+/', '', $snum); if ($snum !== '') { $cursuffix = $this->_exponent[$power][count($this->_exponent[$power])-1]; if ($powsuffix != '') { $cursuffix .= $this->_sep . $powsuffix; } $ret .= $this->_toWords($snum, $p, $cursuffix); } $curp = $p - 1; continue; } } $num = substr($num, $maxp - $curp, $curp - $p + 1); if ($num == 0) { return $ret; } } elseif ($num == 0 || $num == '') { return $this->_sep . $this->_digits[0]; } $h = $t = $d = 0; switch(strlen($num)) { case 3: $h = (int)substr($num, -3, 1); case 2: $t = (int)substr($num, -2, 1); case 1: $d = (int)substr($num, -1, 1); break; case 0: return; break; } if ($h) { $ret .= $this->_sep . $this->_digits[$h] . $this->_sep . 'honderd'; } // add digits only in <0>,<1,9> and <21,inf> if ($t != 1 && $d > 0) { if ($t > 0) { $ret .= $this->_digits[$d] . 'en'; } else { $ret .= $this->_digits[$d]; if ($d == 1) { if ($power == 0) { $ret .= 's'; // fuer eins } else { if ($power != 3) { // tausend ausnehmen $ret .= ''; // fuer eine } } } } } // ten, twenty etc. switch ($t) { case 9: case 8: case 7: case 6: case 5: $ret .= $this->_sep . $this->_digits[$t] . 'tig'; break; case 4: $ret .= $this->_sep . 'veertig'; break; case 3: $ret .= $this->_sep . 'dertig'; break; case 2: $ret .= $this->_sep . 'twintig'; break; case 1: switch ($d) { case 0: $ret .= $this->_sep . 'tien'; break; case 1: $ret .= $this->_sep . 'elf'; break; case 2: $ret .= $this->_sep . 'twaalf'; break; case 3: $ret .= $this->_sep . 'dertien'; break; case 4: $ret .= $this->_sep . 'veertien'; break; case 5: case 6: case 7: case 8: case 9: $ret .= $this->_sep . $this->_digits[$d] . 'tien'; break; } break; } if ($power > 0) { if (isset($this->_exponent[$power])) { $lev = $this->_exponent[$power]; } if (!isset($lev) || !is_array($lev)) { return null; } if ($power == 3) { $ret .= $this->_sep . $lev[0]; } elseif ($d == 1 && ($t+$h) == 0) { $ret .= $this->_sep2 . $lev[0] . $this->_sep2; } else { $ret .= $this->_sep2 . $lev[1] . $this->_sep2; } } if ($powsuffix != '') { $ret .= $this->_sep . $powsuffix; } return $ret; } // }}} } Numbers_Words-0.16.4/Numbers/Words/lang.pl.php0000644000076500007650000004357311732225114017656 0ustar igorigor * @license PHP 3.01 http://www.php.net/license/3_01.txt * @version SVN: $Id$ * @link http://pear.php.net/package/Numbers_Words */ /** * Class for translating numbers into Polish. * * @author Piotr Klaban * @package Numbers_Words */ /** * Include needed files */ require_once "Numbers/Words.php"; /** * Class for translating numbers into Polish. * * @category Numbers * @package Numbers_Words * @author Piotr Klaban * @license PHP 3.01 http://www.php.net/license/3_01.txt * @link http://pear.php.net/package/Numbers_Words */ class Numbers_Words_pl extends Numbers_Words { // {{{ properties /** * Locale name * @var string * @access public */ var $locale = 'pl'; /** * Language name in English * @var string * @access public */ var $lang = 'Polish'; /** * Native language name * @var string * @access public */ var $lang_native = 'polski'; /** * The word for the minus sign * @var string * @access private */ var $_minus = 'minus'; // minus sign /** * The sufixes for exponents (singular and plural) * Names based on: * mathematical tables, my memory, and also: * http://ux1.math.us.edu.pl/~szyjewski/FAQ/liczby/iony.htm * @var array * @access private */ var $_exponent = array( // potêga dziesi±tki => liczba pojedyncza, podwójna, mnoga 0 => array('','',''), 3 => array('tysi±c','tysi±ce','tysiêcy'), 6 => array('milion','miliony','milionów'), 9 => array('miliard','miliardy','miliardów'), 12 => array('bilion','biliony','bilionów'), 15 => array('biliard','biliardy','biliardów'), 18 => array('trylion','tryliony','trylionów'), 21 => array('tryliard','tryliardy','tryliardów'), 24 => array('kwadrylion','kwadryliony','kwadrylionów'), 27 => array('kwadryliard','kwadryliardy','kwadryliardów'), 30 => array('kwintylion','kwintyliony','kwintylionów'), 33 => array('kwintyliiard','kwintyliardy','kwintyliardów'), 36 => array('sekstylion','sekstyliony','sekstylionów'), 39 => array('sekstyliard','sekstyliardy','sekstyliardów'), 42 => array('septylion','septyliony','septylionów'), 45 => array('septyliard','septyliardy','septyliardów'), 48 => array('oktylion','oktyliony','oktylionów'), 51 => array('oktyliard','oktyliardy','oktyliardów'), 54 => array('nonylion','nonyliony','nonylionów'), 57 => array('nonyliard','nonyliardy','nonyliardów'), 60 => array('decylion','decyliony','decylionów'), 63 => array('decyliard','decyliardy','decyliardów'), 100 => array('centylion','centyliony','centylionów'), 103 => array('centyliard','centyliardy','centyliardów'), 120 => array('wicylion','wicylion','wicylion'), 123 => array('wicyliard','wicyliardy','wicyliardów'), 180 => array('trycylion','trycylion','trycylion'), 183 => array('trycyliard','trycyliardy','trycyliardów'), 240 => array('kwadragilion','kwadragilion','kwadragilion'), 243 => array('kwadragiliard','kwadragiliardy','kwadragiliardów'), 300 => array('kwinkwagilion','kwinkwagilion','kwinkwagilion'), 303 => array('kwinkwagiliard','kwinkwagiliardy','kwinkwagiliardów'), 360 => array('seskwilion','seskwilion','seskwilion'), 363 => array('seskwiliard','seskwiliardy','seskwiliardów'), 420 => array('septagilion','septagilion','septagilion'), 423 => array('septagiliard','septagiliardy','septagiliardów'), 480 => array('oktogilion','oktogilion','oktogilion'), 483 => array('oktogiliard','oktogiliardy','oktogiliardów'), 540 => array('nonagilion','nonagilion','nonagilion'), 543 => array('nonagiliard','nonagiliardy','nonagiliardów'), 600 => array('centylion','centyliony','centylionów'), 603 => array('centyliard','centyliardy','centyliardów'), 6000018 => array('milinilitrylion','milinilitryliony','milinilitrylionów') ); /** * The array containing the digits (indexed by the digits themselves). * @var array * @access private */ var $_digits = array( 0 => 'zero', 'jeden', 'dwa', 'trzy', 'cztery', 'piêæ', 'sze¶æ', 'siedem', 'osiem', 'dziewiêæ' ); /** * The word separator * @var string * @access private */ var $_sep = ' '; /** * The currency names (based on the below links, * informations from central bank websites and on encyclopedias) * * @var array * @link http://www.xe.com/iso4217.htm Currency codes * @link http://www.republika.pl/geographia/peuropy.htm Europe review * @link http://pieniadz.hoga.pl/waluty_objasnienia.asp Currency service * @access private */ var $_currency_names = array( 'ALL' => array(array('lek','leki','leków'), array('quindarka','quindarki','quindarek')), 'AUD' => array(array('dolar australijski', 'dolary australijskie', 'dolarów australijskich'), array('cent', 'centy', 'centów')), 'BAM' => array(array('marka','marki','marek'), array('fenig','fenigi','fenigów')), 'BGN' => array(array('lew','lewy','lew'), array('stotinka','stotinki','stotinek')), 'BRL' => array(array('real','reale','realów'), array('centavos','centavos','centavos')), 'BYR' => array(array('rubel','ruble','rubli'), array('kopiejka','kopiejki','kopiejek')), 'CAD' => array(array('dolar kanadyjski', 'dolary kanadyjskie', 'dolarów kanadyjskich'), array('cent', 'centy', 'centów')), 'CHF' => array(array('frank szwajcarski','franki szwajcarskie','franków szwajcarskich'), array('rapp','rappy','rappów')), 'CYP' => array(array('funt cypryjski','funty cypryjskie','funtów cypryjskich'), array('cent', 'centy', 'centów')), 'CZK' => array(array('korona czeska','korony czeskie','koron czeskich'), array('halerz','halerze','halerzy')), 'DKK' => array(array('korona duñska','korony duñskie','koron duñskich'), array('ore','ore','ore')), 'EEK' => array(array('korona estoñska','korony estoñskie','koron estoñskich'), array('senti','senti','senti')), 'EUR' => array(array('euro', 'euro', 'euro'), array('eurocent', 'eurocenty', 'eurocentów')), 'GBP' => array(array('funt szterling','funty szterlingi','funtów szterlingów'), array('pens','pensy','pensów')), 'HKD' => array(array('dolar Hongkongu','dolary Hongkongu','dolarów Hongkongu'), array('cent', 'centy', 'centów')), 'HRK' => array(array('kuna','kuny','kun'), array('lipa','lipy','lip')), 'HUF' => array(array('forint','forinty','forintów'), array('filler','fillery','fillerów')), 'ILS' => array(array('nowy szekel','nowe szekele','nowych szekeli'), array('agora','agory','agorot')), 'ISK' => array(array('korona islandzka','korony islandzkie','koron islandzkich'), array('aurar','aurar','aurar')), 'JPY' => array(array('jen','jeny','jenów'), array('sen','seny','senów')), 'LTL' => array(array('lit','lity','litów'), array('cent', 'centy', 'centów')), 'LVL' => array(array('³at','³aty','³atów'), array('sentim','sentimy','sentimów')), 'MKD' => array(array('denar','denary','denarów'), array('deni','deni','deni')), 'MTL' => array(array('lira maltañska','liry maltañskie','lir maltañskich'), array('centym','centymy','centymów')), 'NOK' => array(array('korona norweska','korony norweskie','koron norweskich'), array('oere','oere','oere')), 'PLN' => array(array('z³oty', 'z³ote', 'z³otych'), array('grosz', 'grosze', 'groszy')), 'ROL' => array(array('lej','leje','lei'), array('bani','bani','bani')), 'RUB' => array(array('rubel','ruble','rubli'), array('kopiejka','kopiejki','kopiejek')), 'SEK' => array(array('korona szwedzka','korony szwedzkie','koron szweckich'), array('oere','oere','oere')), 'SIT' => array(array('tolar','tolary','tolarów'), array('stotinia','stotinie','stotini')), 'SKK' => array(array('korona s³owacka','korony s³owackie','koron s³owackich'), array('halerz','halerze','halerzy')), 'TRL' => array(array('lira turecka','liry tureckie','lir tureckich'), array('kurusza','kurysze','kuruszy')), 'UAH' => array(array('hrywna','hrywna','hrywna'), array('cent', 'centy', 'centów')), 'USD' => array(array('dolar','dolary','dolarów'), array('cent', 'centy', 'centów')), 'YUM' => array(array('dinar','dinary','dinarów'), array('para','para','para')), 'ZAR' => array(array('rand','randy','randów'), array('cent', 'centy', 'centów')) ); /** * The default currency name * @var string * @access public */ var $def_currency = 'PLN'; // Polish zloty // }}} // {{{ _toWords() /** * Converts a number to its word representation * in Polish language * * @param integer $num An integer between -infinity and infinity inclusive :) * that need to be converted to words * @param integer $power The power of ten for the rest of the number to the right. * Optional, defaults to 0. * @param integer $powsuffix The power name to be added to the end of the return string. * Used internally. Optional, defaults to ''. * * @return string The corresponding word representation * * @access protected * @author Piotr Klaban * @since Numbers_Words 0.16.3 */ function _toWords($num, $power = 0, $powsuffix = '') { $ret = ''; // add a minus sign if (substr($num, 0, 1) == '-') { $ret = $this->_sep . $this->_minus; $num = substr($num, 1); } // strip excessive zero signs and spaces $num = trim($num); $num = preg_replace('/^0+/', '', $num); if (strlen($num) > 3) { $maxp = strlen($num)-1; $curp = $maxp; for ($p = $maxp; $p > 0; --$p) { // power // check for highest power if (isset($this->_exponent[$p])) { // send substr from $curp to $p $snum = substr($num, $maxp - $curp, $curp - $p + 1); $snum = preg_replace('/^0+/', '', $snum); if ($snum !== '') { $cursuffix = $this->_exponent[$power][count($this->_exponent[$power])-1]; if ($powsuffix != '') { $cursuffix .= $this->_sep . $powsuffix; } $ret .= $this->_toWords($snum, $p, $cursuffix); } $curp = $p - 1; continue; } } $num = substr($num, $maxp - $curp, $curp - $p + 1); if ($num == 0) { return $ret; } } elseif ($num == 0 || $num == '') { return $this->_sep . $this->_digits[0]; } $h = $t = $d = 0; switch(strlen($num)) { case 3: $h = (int)substr($num, -3, 1); case 2: $t = (int)substr($num, -2, 1); case 1: $d = (int)substr($num, -1, 1); break; case 0: return; break; } switch ($h) { case 9: $ret .= $this->_sep . 'dziewiêæset'; break; case 8: $ret .= $this->_sep . 'osiemset'; break; case 7: $ret .= $this->_sep . 'siedemset'; break; case 6: $ret .= $this->_sep . 'sze¶æset'; break; case 5: $ret .= $this->_sep . 'piêæset'; break; case 4: $ret .= $this->_sep . 'czterysta'; break; case 3: $ret .= $this->_sep . 'trzysta'; break; case 2: $ret .= $this->_sep . 'dwie¶cie'; break; case 1: $ret .= $this->_sep . 'sto'; break; } switch ($t) { case 9: case 8: case 7: case 6: case 5: $ret .= $this->_sep . $this->_digits[$t] . 'dziesi±t'; break; case 4: $ret .= $this->_sep . 'czterdzie¶ci'; break; case 3: $ret .= $this->_sep . 'trzydzie¶ci'; break; case 2: $ret .= $this->_sep . 'dwadzie¶cia'; break; case 1: switch ($d) { case 0: $ret .= $this->_sep . 'dziesiêæ'; break; case 1: $ret .= $this->_sep . 'jedena¶cie'; break; case 2: case 3: case 7: case 8: $ret .= $this->_sep . $this->_digits[$d] . 'na¶cie'; break; case 4: $ret .= $this->_sep . 'czterna¶cie'; break; case 5: $ret .= $this->_sep . 'piêtna¶cie'; break; case 6: $ret .= $this->_sep . 'szesna¶cie'; break; case 9: $ret .= $this->_sep . 'dziewiêtna¶cie'; break; } break; } if ($t != 1 && $d > 0) { $ret .= $this->_sep . $this->_digits[$d]; } if ($t == 1) { $d = 0; } if (( $h + $t ) > 0 && $d == 1) { $d = 0; } if ($power > 0) { if (isset($this->_exponent[$power])) { $lev = $this->_exponent[$power]; } if (!isset($lev) || !is_array($lev)) { return null; } switch ($d) { case 1: $suf = $lev[0]; break; case 2: case 3: case 4: $suf = $lev[1]; break; case 0: case 5: case 6: case 7: case 8: case 9: $suf = $lev[2]; break; } $ret .= $this->_sep . $suf; } if ($powsuffix != '') { $ret .= $this->_sep . $powsuffix; } return $ret; } // }}} // {{{ toCurrencyWords() /** * Converts a currency value to its word representation * (with monetary units) in Polish language * * @param integer $int_curr An international currency symbol * as defined by the ISO 4217 standard (three characters) * @param integer $decimal A money total amount without fraction part (e.g. amount of dollars) * @param integer $fraction Fractional part of the money amount (e.g. amount of cents) * Optional. Defaults to false. * @param integer $convert_fraction Convert fraction to words (left as numeric if set to false). * Optional. Defaults to true. * * @return string The corresponding word representation for the currency * * @access public * @author Piotr Klaban * @since Numbers_Words 0.4 */ function toCurrencyWords($int_curr, $decimal, $fraction = false, $convert_fraction = true) { $int_curr = strtoupper($int_curr); if (!isset($this->_currency_names[$int_curr])) { $int_curr = $this->def_currency; } $curr_names = $this->_currency_names[$int_curr]; $ret = trim($this->_toWords($decimal)); $lev = $this->_get_numlevel($decimal); $ret .= $this->_sep . $curr_names[0][$lev]; if ($fraction !== false) { if ($convert_fraction) { $ret .= $this->_sep . trim($this->_toWords($fraction)); } else { $ret .= $this->_sep . $fraction; } $lev = $this->_get_numlevel($fraction); $ret .= $this->_sep . $curr_names[1][$lev]; } return $ret; } // }}} // {{{ _get_numlevel() /** * Returns grammatical "level" of the number - this is necessary * for choosing the right suffix for exponents and currency names. * * @param integer $num An integer between -infinity and infinity inclusive * that need to be converted to words * * @return integer The grammatical "level" of the number. * * @access private * @author Piotr Klaban * @since Numbers_Words 0.4 */ function _get_numlevel($num) { if (strlen($num) > 3) { $num = substr($num, -3); } $num = (int) $num; $h = $t = $d = $lev = 0; switch (strlen($num)) { case 3: $h = (int)substr($num, -3, 1); case 2: $t = (int)substr($num, -2, 1); case 1: $d = (int)substr($num, -1, 1); break; case 0: return $lev; break; } if ($t == 1) { $d = 0; } if (( $h + $t ) > 0 && $d == 1) { $d = 0; } switch ($d) { case 1: $lev = 0; break; case 2: case 3: case 4: $lev = 1; break; default: $lev = 2; } return $lev; } // }}} } Numbers_Words-0.16.4/Numbers/Words/lang.pt_BR.php0000644000076500007650000003414711732225114020246 0ustar igorigor * @license PHP 3.01 http://www.php.net/license/3_01.txt * @version SVN: $Id$ * @link http://pear.php.net/package/Numbers_Words */ /** * Include needed files */ require_once "Numbers/Words.php"; /** * Class for translating numbers into Brazilian Portuguese. This class complies * to Brazilian Academy of Letters rules as of 2008-12-12. * * @category Numbers * @package Numbers_Words * @author Igor Feghali * @license PHP 3.01 http://www.php.net/license/3_01.txt * @link http://pear.php.net/package/Numbers_Words */ class Numbers_Words_pt_BR extends Numbers_Words { /** * Locale name * @var string * @access public */ var $locale = 'pt_BR'; /** * Language name in English * @var string * @access public */ var $lang = 'Brazilian Portuguese'; /** * Native language name * @var string * @access public */ var $lang_native = 'Português Brasileiro'; /** * The word for the minus sign * @var string * @access private */ var $_minus = 'negativo'; /** * The word separator for numerals * @var string * @access private */ var $_sep = ' e '; /** * The special separator for numbers and currency names * @var string * @access private */ var $_curr_sep = ' de '; /** * The array containing numbers 11-19. * In Brazilian Portuguese numbers in that range are contracted * in a single word. * @var array * @access private */ var $_contractions = array( '', 'onze', 'doze', 'treze', 'quatorze', 'quinze', 'dezesseis', 'dezessete', 'dezoito', 'dezenove' ); var $_words = array( /** * The array containing the digits (indexed by the digits themselves). * @var array * @access private */ array( '', // 0: not displayed 'um', 'dois', 'três', 'quatro', 'cinco', 'seis', 'sete', 'oito', 'nove' ), /** * The array containing numbers for 10,20,...,90. * @var array * @access private */ array( '', // 0: not displayed 'dez', 'vinte', 'trinta', 'quarenta', 'cinqüenta', 'sessenta', 'setenta', 'oitenta', 'noventa' ), /** * The array containing numbers for hundreds. * @var array * @access private */ array( '', // 0: not displayed 'cento', // 'cem' is a special case handled in _toWords() 'duzentos', 'trezentos', 'quatrocentos', 'quinhentos', 'seiscentos', 'setecentos', 'oitocentos', 'novecentos' ), ); /** * The sufixes for exponents (singular) * @var array * @access private */ var $_exponent = array( '', // 0: not displayed 'mil', 'milhão', 'bilhão', 'trilhão', 'quatrilhão', 'quintilhão', 'sextilhão', 'septilhão', 'octilhão', 'nonilhão', 'decilhão', 'undecilhão', 'dodecilhão', 'tredecilhão', 'quatuordecilhão', 'quindecilhão', 'sedecilhão', 'septendecilhão' ); /** * The currency names (based on Wikipedia) and plurals * * @var array * @link http://pt.wikipedia.org/wiki/ISO_4217 * @access private */ var $_currency_names = array( 'BRL' => array(array('real', 'reais'), array('centavo', 'centavos')), 'USD' => array(array('dólar', 'dólares'), array('centavo', 'centavos')), 'EUR' => array(array('euro', 'euros'), array('centavo', 'centavos')), 'GBP' => array(array('libra esterlina', 'libras esterlinas'), array('centavo', 'centavos')), 'JPY' => array(array('iene', 'ienes'), array('centavo', 'centavos')), 'ARS' => array(array('peso argentino', 'pesos argentinos'), array('centavo', 'centavos')), 'MXN' => array(array('peso mexicano', 'pesos mexicanos'), array('centavo', 'centavos')), 'UYU' => array(array('peso uruguaio', 'pesos uruguaios'), array('centavo', 'centavos')), 'PYG' => array(array('guarani', 'guaranis'), array('centavo', 'centavos')), 'BOB' => array(array('boliviano', 'bolivianos'), array('centavo', 'centavos')), 'CLP' => array(array('peso chileno', 'pesos chilenos'), array('centavo', 'centavos')), 'COP' => array(array('peso colombiano', 'pesos colombianos'), array('centavo', 'centavos')), 'CUP' => array(array('peso cubano', 'pesos cubanos'), array('centavo', 'centavos')), ); /** * The default currency name * @var string * @access public */ var $def_currency = 'BRL'; // Real // {{{ _toWords() /** * Converts a number to its word representation * in Brazilian Portuguese language * * @param integer $num An integer between -999E54 and 999E54 * * @return string The corresponding word representation * * @access protected * @author Igor Feghali * @since Numbers_Words 0.16.3 */ function _toWords($num) { $neg = 0; $ret = array(); $words = array(); /** * Negative ? */ if ($num < 0) { $ret[] = $this->_minus; $num = -$num; $neg = 1; } /** * Removes leading zeros, spaces, decimals etc. * Adds thousands separator. */ $num = number_format($num, 0, '.', '.'); /** * Testing Zero */ if ($num == 0) { return 'zero'; } /** * Breaks into chunks of 3 digits. * Reversing array to process from right to left. */ $chunks = array_reverse(explode(".", $num)); /** * Looping through the chunks */ foreach ($chunks as $index => $chunk) { /** * Testing Range */ if (!array_key_exists($index, $this->_exponent)) { return Numbers_Words::raiseError('Number out of range.'); } /** * Testing Zero */ if ($chunk == 0) { continue; } /** * Testing plural of exponent */ if ($chunk > 1) { $exponent = str_replace('ão', 'ões', $this->_exponent[$index]); } else { $exponent = $this->_exponent[$index]; } /** * Adding exponent */ $ret[] = $exponent; /** * Actual Number */ $word = array_filter($this->_parseChunk($chunk)); $ret[] = implode($this->_sep, $word); } /** * In Brazilian Portuguese the last chunck must be separated under * special conditions. */ if ((count($ret) > 2+$neg) && $this->_mustSeparate($chunks)) { $ret[1+$neg] = trim($this->_sep.$ret[1+$neg]); } $ret = array_reverse(array_filter($ret)); return implode(' ', $ret); } // }}} // {{{ _parseChunck() /** * Recursive function that parses an indivial chunk * * @param string $chunk String representation of a 3-digit-max number * * @return array Words of parsed number * * @access private * @author Igor Feghali * @since Numbers_Words 0.15.1 */ function _parseChunk($chunk) { /** * Base Case */ if (!$chunk) { return array(); } /** * 100 is a special case */ if ($chunk == 100) { return array('cem'); } /** * Testing contractions (11~19) */ if (($chunk < 20) && ($chunk > 10)) { return array($this->_contractions[$chunk % 10]); } $i = strlen($chunk)-1; $n = (int)$chunk[0]; $word = $this->_words[$i][$n]; return array_merge(array($word), $this->_parseChunk(substr($chunk, 1))); } // }}} // {{{ _mustSeparate() /** * In Brazilian Portuguese the last chunk must be separated from the others * when it is a hundred (100, 200, 300 etc.) or less than 100. * * @param array $chunks Array of integers that contains all the chunks of * the target number, in reverse order. * * @return boolean Returns true when last chunk must be separated * * @access private * @author Igor Feghali * @since Numbers_Words 0.15.1 */ function _mustSeparate($chunks) { $chunk = null; /** * Find first occurrence != 0. * (first chunk in array but last logical chunk) */ reset($chunks); do { list(,$chunk) = each($chunks); } while ($chunk === '000'); if (($chunk < 100) || !($chunk % 100)) { return true; } return false; } // }}} // {{{ toCurrencyWords() /** * Converts a currency value to its word representation * (with monetary units) in Portuguese Brazilian * * @param integer $int_curr An international currency symbol * as defined by the ISO 4217 standard (three characters) * @param integer $decimal A money total amount without fraction part (e.g. amount of dollars) * @param integer $fraction Fractional part of the money amount (e.g. amount of cents) * Optional. Defaults to false. * @param integer $convert_fraction Convert fraction to words (left as numeric if set to false). * Optional. Defaults to true. * * @return string The corresponding word representation for the currency * * @access public * @author Igor Feghali * @since Numbers_Words 0.11.0 */ function toCurrencyWords($int_curr, $decimal, $fraction = false, $convert_fraction = true) { $neg = 0; $ret = array(); $nodec = false; /** * Negative ? * We can lose the '-' sign if we do the * check after number_format() call (i.e. -0.01) */ if (substr($decimal, 0, 1) == '-') { $decimal = -$decimal; $neg = 1; } /** * Removes leading zeros, spaces, decimals etc. * Adds thousands separator. */ $num = number_format($decimal, 0, '', ''); /** * Checking if given currency exists in driver. * If not, use default currency */ $int_curr = strtoupper($int_curr); if (!isset($this->_currency_name[$int_curr])) { $int_curr = $this->def_currency; } /** * Currency names and plural */ $curr_names = $this->_currency_names[$int_curr]; if ($num > 0) { /** * Word representation of decimal */ $ret[] = $this->_toWords($num); /** * Special case. */ if (substr($num, -6) == '000000') { $ret[] = trim($this->_curr_sep); } /** * Testing plural. Adding currency name */ if ($num > 1) { $ret[] = $curr_names[0][1]; } else { $ret[] = $curr_names[0][0]; } } /** * Test if fraction was given and != 0 */ $fraction = (int)$fraction; if ($fraction) { /** * Removes leading zeros, spaces, decimals etc. * Adds thousands separator. */ $num = number_format($fraction, 0, '.', '.'); /** * Testing Range */ if ($num < 0 || $num > 99) { return Numbers_Words::raiseError('Fraction out of range.'); } /** * Have we got decimal? */ if (count($ret)) { $ret[] = trim($this->_sep); } else { $nodec = true; } /** * Word representation of fraction */ if ($convert_fraction) { $ret[] = $this->_toWords($num); } else { $ret[] = $num; } /** * Testing plural */ if ($num > 1) { $ret[] = $curr_names[1][1]; } else { $ret[] = $curr_names[1][0]; } /** * Have we got decimal? * If not, include currency name after cents. */ if ($nodec) { $ret[] = trim($this->_curr_sep); $ret[] = $curr_names[0][0]; } } /** * Negative ? */ if ($neg) { $ret[] = $this->_minus; } return implode(' ', $ret); } // }}} } Numbers_Words-0.16.4/Numbers/Words/lang.ru.php0000644000076500007650000005174111732225114017665 0ustar igorigor * @author Andrey Demenev * @license PHP 3.01 http://www.php.net/license/3_01.txt * @version SVN: $Id$ * @link http://pear.php.net/package/Numbers_Words */ /** * Class for translating numbers into Russian. * * @author Andrey Demenev * @package Numbers_Words */ /** * Include needed files */ require_once "Numbers/Words.php"; /** * Class for translating numbers into Russian. * * @category Numbers * @package Numbers_Words * @author Piotr Klaban * @author Andrey Demenev * @license PHP 3.01 http://www.php.net/license/3_01.txt * @link http://pear.php.net/package/Numbers_Words */ class Numbers_Words_ru extends Numbers_Words { // {{{ properties /** * Locale name * @var string * @access public */ var $locale = 'ru'; /** * Language name in English * @var string * @access public */ var $lang = 'Russian'; /** * Native language name * @var string * @access public */ var $lang_native = 'Ðóññêèé'; /** * The word for the minus sign * @var string * @access private */ var $_minus = 'ìèíóñ'; // minus sign /** * The sufixes for exponents (singular) * Names partly based on: * http://home.earthlink.net/~mrob/pub/math/largenum.html * http://mathforum.org/dr.math/faq/faq.large.numbers.html * http://www.mazes.com/AmericanNumberingSystem.html * @var array * @access private */ var $_exponent = array( 0 => '', 6 => 'ìèëëèîí', 9 => 'ìèëëèàðä', 12 => 'òðèëëèîí', 15 => 'êâàäðèëëèîí', 18 => 'êâèíòèëëèîí', 21 => 'ñåêñòèëëèîí', 24 => 'ñåïòèëëèîí', 27 => 'îêòèëëèîí', 30 => 'íîíèëëèîí', 33 => 'äåöèëëèîí', 36 => 'óíäåöèëëèîí', 39 => 'äóîäåöèëëèîí', 42 => 'òðåäåöèëëèîí', 45 => 'êâàòóîðäåöèëëèîí', 48 => 'êâèíäåöèëëèîí', 51 => 'ñåêñäåöèëëèîí', 54 => 'ñåïòåíäåöèëëèîí', 57 => 'îêòîäåöèëëèîí', 60 => 'íîâåìäåöèëëèîí', 63 => 'âèãèíòèëëèîí', 66 => 'óíâèãèíòèëëèîí', 69 => 'äóîâèãèíòèëëèîí', 72 => 'òðåâèãèíòèëëèîí', 75 => 'êâàòóîðâèãèíòèëëèîí', 78 => 'êâèíâèãèíòèëëèîí', 81 => 'ñåêñâèãèíòèëëèîí', 84 => 'ñåïòåíâèãèíòèëëèîí', 87 => 'îêòîâèãèíòèëëèîí', 90 => 'íîâåìâèãèíòèëëèîí', 93 => 'òðèãèíòèëëèîí', 96 => 'óíòðèãèíòèëëèîí', 99 => 'äóîòðèãèíòèëëèîí', 102 => 'òðåòðèãèíòèëëèîí', 105 => 'êâàòîðòðèãèíòèëëèîí', 108 => 'êâèíòðèãèíòèëëèîí', 111 => 'ñåêñòðèãèíòèëëèîí', 114 => 'ñåïòåíòðèãèíòèëëèîí', 117 => 'îêòîòðèãèíòèëëèîí', 120 => 'íîâåìòðèãèíòèëëèîí', 123 => 'êâàäðàãèíòèëëèîí', 126 => 'óíêâàäðàãèíòèëëèîí', 129 => 'äóîêâàäðàãèíòèëëèîí', 132 => 'òðåêâàäðàãèíòèëëèîí', 135 => 'êâàòîðêâàäðàãèíòèëëèîí', 138 => 'êâèíêâàäðàãèíòèëëèîí', 141 => 'ñåêñêâàäðàãèíòèëëèîí', 144 => 'ñåïòåíêâàäðàãèíòèëëèîí', 147 => 'îêòîêâàäðàãèíòèëëèîí', 150 => 'íîâåìêâàäðàãèíòèëëèîí', 153 => 'êâèíêâàãèíòèëëèîí', 156 => 'óíêâèíêàãèíòèëëèîí', 159 => 'äóîêâèíêàãèíòèëëèîí', 162 => 'òðåêâèíêàãèíòèëëèîí', 165 => 'êâàòîðêâèíêàãèíòèëëèîí', 168 => 'êâèíêâèíêàãèíòèëëèîí', 171 => 'ñåêñêâèíêàãèíòèëëèîí', 174 => 'ñåïòåíêâèíêàãèíòèëëèîí', 177 => 'îêòîêâèíêàãèíòèëëèîí', 180 => 'íîâåìêâèíêàãèíòèëëèîí', 183 => 'ñåêñàãèíòèëëèîí', 186 => 'óíñåêñàãèíòèëëèîí', 189 => 'äóîñåêñàãèíòèëëèîí', 192 => 'òðåñåêñàãèíòèëëèîí', 195 => 'êâàòîðñåêñàãèíòèëëèîí', 198 => 'êâèíñåêñàãèíòèëëèîí', 201 => 'ñåêññåêñàãèíòèëëèîí', 204 => 'ñåïòåíñåêñàãèíòèëëèîí', 207 => 'îêòîñåêñàãèíòèëëèîí', 210 => 'íîâåìñåêñàãèíòèëëèîí', 213 => 'ñåïòàãèíòèëëèîí', 216 => 'óíñåïòàãèíòèëëèîí', 219 => 'äóîñåïòàãèíòèëëèîí', 222 => 'òðåñåïòàãèíòèëëèîí', 225 => 'êâàòîðñåïòàãèíòèëëèîí', 228 => 'êâèíñåïòàãèíòèëëèîí', 231 => 'ñåêññåïòàãèíòèëëèîí', 234 => 'ñåïòåíñåïòàãèíòèëëèîí', 237 => 'îêòîñåïòàãèíòèëëèîí', 240 => 'íîâåìñåïòàãèíòèëëèîí', 243 => 'îêòîãèíòèëëèîí', 246 => 'óíîêòîãèíòèëëèîí', 249 => 'äóîîêòîãèíòèëëèîí', 252 => 'òðåîêòîãèíòèëëèîí', 255 => 'êâàòîðîêòîãèíòèëëèîí', 258 => 'êâèíîêòîãèíòèëëèîí', 261 => 'ñåêñîêòîãèíòèëëèîí', 264 => 'ñåïòîêòîãèíòèëëèîí', 267 => 'îêòîîêòîãèíòèëëèîí', 270 => 'íîâåìîêòîãèíòèëëèîí', 273 => 'íîíàãèíòèëëèîí', 276 => 'óííîíàãèíòèëëèîí', 279 => 'äóîíîíàãèíòèëëèîí', 282 => 'òðåíîíàãèíòèëëèîí', 285 => 'êâàòîðíîíàãèíòèëëèîí', 288 => 'êâèííîíàãèíòèëëèîí', 291 => 'ñåêñíîíàãèíòèëëèîí', 294 => 'ñåïòåííîíàãèíòèëëèîí', 297 => 'îêòîíîíàãèíòèëëèîí', 300 => 'íîâåìíîíàãèíòèëëèîí', 303 => 'öåíòèëëèîí' ); /** * The array containing the teens' :) names * @var array * @access private */ var $_teens = array( 11=>'îäèííàäöàòü', 12=>'äâåíàäöàòü', 13=>'òðèíàäöàòü', 14=>'÷åòûðíàäöàòü', 15=>'ïÿòíàäöàòü', 16=>'øåñòíàäöàòü', 17=>'ñåìíàäöàòü', 18=>'âîñåìíàäöàòü', 19=>'äåâÿòíàäöàòü' ); /** * The array containing the tens' names * @var array * @access private */ var $_tens = array( 2=>'äâàäöàòü', 3=>'òðèäöàòü', 4=>'ñîðîê', 5=>'ïÿòüäåñÿò', 6=>'øåñòüäåñÿò', 7=>'ñåìüäåñÿò', 8=>'âîñåìüäåñÿò', 9=>'äåâÿíîñòî' ); /** * The array containing the hundreds' names * @var array * @access private */ var $_hundreds = array( 1=>'ñòî', 2=>'äâåñòè', 3=>'òðèñòà', 4=>'÷åòûðåñòà', 5=>'ïÿòüñîò', 6=>'øåñòüñîò', 7=>'ñåìüñîò', 8=>'âîñåìüñîò', 9=>'äåâÿòüñîò' ); /** * The array containing the digits * for neutral, male and female * @var array * @access private */ var $_digits = array( array('íîëü', 'îäíî', 'äâà', 'òðè', '÷åòûðå', 'ïÿòü', 'øåñòü', 'ñåìü', 'âîñåìü', 'äåâÿòü'), array('íîëü', 'îäèí', 'äâà', 'òðè', '÷åòûðå', 'ïÿòü', 'øåñòü', 'ñåìü', 'âîñåìü', 'äåâÿòü'), array('íîëü', 'îäíà', 'äâå', 'òðè', '÷åòûðå', 'ïÿòü', 'øåñòü', 'ñåìü', 'âîñåìü', 'äåâÿòü') ); /** * The word separator * @var string * @access private */ var $_sep = ' '; /** * The currency names (based on the below links, * informations from central bank websites and on encyclopedias) * * @var array * @link http://www.jhall.demon.co.uk/currency/by_abbrev.html World currencies * @link http://www.rusimpex.ru/Content/Reference/Refinfo/valuta.htm Foreign currencies names * @link http://www.cofe.ru/Finance/money.asp Currencies names * @access private */ var $_currency_names = array( 'ALL' => array( array(1, 'ëåê', 'ëåêà', 'ëåêîâ'), array(2, 'êèíäàðêà', 'êèíäàðêè', 'êèíäàðîê') ), 'AUD' => array( array(1, 'àâñòðàëèéñêèé äîëëàð', 'àâñòðàëèéñêèõ äîëëàðà', 'àâñòðàëèéñêèõ äîëëàðîâ'), array(1, 'öåíò', 'öåíòà', 'öåíòîâ') ), 'BGN' => array( array(1, 'ëåâ', 'ëåâà', 'ëåâîâ'), array(2, 'ñòîòèíêà', 'ñòîòèíêè', 'ñòîòèíîê') ), 'BRL' => array( array(1, 'áðàçèëüñêèé ðåàë', 'áðàçèëüñêèõ ðåàëà', 'áðàçèëüñêèõ ðåàëîâ'), array(1, 'ñåíòàâî', 'ñåíòàâî', 'ñåíòàâî') ), 'BYR' => array( array(1, 'áåëîðóññêèé ðóáëü', 'áåëîðóññêèõ ðóáëÿ', 'áåëîðóññêèõ ðóáëåé'), array(2, 'êîïåéêà', 'êîïåéêè', 'êîïååê') ), 'CAD' => array( array(1, 'êàíàäñêèé äîëëàð', 'êàíàäñêèõ äîëëàðà', 'êàíàäñêèõ äîëëàðîâ'), array(1, 'öåíò', 'öåíòà', 'öåíòîâ') ), 'CHF' => array( array(1, 'øâåéöàðñêèé ôðàíê', 'øâåéöàðñêèõ ôðàíêà', 'øâåéöàðñêèõ ôðàíêîâ'), array(1, 'ñàíòèì', 'ñàíòèìà', 'ñàíòèìîâ') ), 'CYP' => array( array(1, 'êèïðñêèé ôóíò', 'êèïðñêèõ ôóíòà', 'êèïðñêèõ ôóíòîâ'), array(1, 'öåíò', 'öåíòà', 'öåíòîâ') ), 'CZK' => array( array(2, '÷åøñêàÿ êðîíà', '÷åøñêèõ êðîíû', '÷åøñêèõ êðîí'), array(1, 'ãàëèðæ', 'ãàëèðæà', 'ãàëèðæåé') ), 'DKK' => array( array(2, 'äàòñêàÿ êðîíà', 'äàòñêèõ êðîíû', 'äàòñêèõ êðîí'), array(1, 'ýðå', 'ýðå', 'ýðå') ), 'EEK' => array( array(2, 'ýñòîíñêàÿ êðîíà', 'ýñòîíñêèõ êðîíû', 'ýñòîíñêèõ êðîí'), array(1, 'ñåíòè', 'ñåíòè', 'ñåíòè') ), 'EUR' => array( array(1, 'åâðî', 'åâðî', 'åâðî'), array(1, 'åâðîöåíò', 'åâðîöåíòà', 'åâðîöåíòîâ') ), 'CYP' => array( array(1, 'ôóíò ñòåðëèíãîâ', 'ôóíòà ñòåðëèíãîâ', 'ôóíòîâ ñòåðëèíãîâ'), array(1, 'ïåíñ', 'ïåíñà', 'ïåíñîâ') ), 'CAD' => array( array(1, 'ãîíêîíãñêèé äîëëàð', 'ãîíêîíãñêèõ äîëëàðà', 'ãîíêîíãñêèõ äîëëàðîâ'), array(1, 'öåíò', 'öåíòà', 'öåíòîâ') ), 'HRK' => array( array(2, 'õîðâàòñêàÿ êóíà', 'õîðâàòñêèõ êóíû', 'õîðâàòñêèõ êóí'), array(2, 'ëèïà', 'ëèïû', 'ëèï') ), 'HUF' => array( array(1, 'âåíãåðñêèé ôîðèíò', 'âåíãåðñêèõ ôîðèíòà', 'âåíãåðñêèõ ôîðèíòîâ'), array(1, 'ôèëëåð', 'ôèëëåðà', 'ôèëëåðîâ') ), 'ISK' => array( array(2, 'èñëàíäñêàÿ êðîíà', 'èñëàíäñêèõ êðîíû', 'èñëàíäñêèõ êðîí'), array(1, 'ýðå', 'ýðå', 'ýðå') ), 'JPY' => array( array(2, 'èåíà', 'èåíû', 'èåí'), array(2, 'ñåíà', 'ñåíû', 'ñåí') ), 'LTL' => array( array(1, 'ëèò', 'ëèòà', 'ëèòîâ'), array(1, 'öåíò', 'öåíòà', 'öåíòîâ') ), 'LVL' => array( array(1, 'ëàò', 'ëàòà', 'ëàòîâ'), array(1, 'ñåíòèì', 'ñåíòèìà', 'ñåíòèìîâ') ), 'MKD' => array( array(1, 'ìàêåäîíñêèé äèíàð', 'ìàêåäîíñêèõ äèíàðà', 'ìàêåäîíñêèõ äèíàðîâ'), array(1, 'äåíè', 'äåíè', 'äåíè') ), 'MTL' => array( array(2, 'ìàëüòèéñêàÿ ëèðà', 'ìàëüòèéñêèõ ëèðû', 'ìàëüòèéñêèõ ëèð'), array(1, 'ñåíòèì', 'ñåíòèìà', 'ñåíòèìîâ') ), 'NOK' => array( array(2, 'íîðâåæñêàÿ êðîíà', 'íîðâåæñêèõ êðîíû', 'íîðâåæñêèõ êðîí'), array(0, 'ýðå', 'ýðå', 'ýðå') ), 'PLN' => array( array(1, 'çëîòûé', 'çëîòûõ', 'çëîòûõ'), array(1, 'ãðîø', 'ãðîøà', 'ãðîøåé') ), 'ROL' => array( array(1, 'ðóìûíñêèé ëåé', 'ðóìûíñêèõ ëåé', 'ðóìûíñêèõ ëåé'), array(1, 'áàíè', 'áàíè', 'áàíè') ), // both RUR and RUR are used, I use RUB for shorter form 'RUB' => array( array(1, 'ðóáëü', 'ðóáëÿ', 'ðóáëåé'), array(2, 'êîïåéêà', 'êîïåéêè', 'êîïååê') ), 'RUR' => array( array(1, 'ðîññèéñêèé ðóáëü', 'ðîññèéñêèõ ðóáëÿ', 'ðîññèéñêèõ ðóáëåé'), array(2, 'êîïåéêà', 'êîïåéêè', 'êîïååê') ), 'SEK' => array( array(2, 'øâåäñêàÿ êðîíà', 'øâåäñêèõ êðîíû', 'øâåäñêèõ êðîí'), array(1, 'ýðå', 'ýðå', 'ýðå') ), 'SIT' => array( array(1, 'ñëîâåíñêèé òîëàð', 'ñëîâåíñêèõ òîëàðà', 'ñëîâåíñêèõ òîëàðîâ'), array(2, 'ñòîòèíà', 'ñòîòèíû', 'ñòîòèí') ), 'SKK' => array( array(2, 'ñëîâàöêàÿ êðîíà', 'ñëîâàöêèõ êðîíû', 'ñëîâàöêèõ êðîí'), array(0, '', '', '') ), 'TRL' => array( array(2, 'òóðåöêàÿ ëèðà', 'òóðåöêèõ ëèðû', 'òóðåöêèõ ëèð'), array(1, 'ïèàñòð', 'ïèàñòðà', 'ïèàñòðîâ') ), 'UAH' => array( array(2, 'ãðèâíà', 'ãðèâíû', 'ãðèâåí'), array(1, 'öåíò', 'öåíòà', 'öåíòîâ') ), 'USD' => array( array(1, 'äîëëàð ÑØÀ', 'äîëëàðà ÑØÀ', 'äîëëàðîâ ÑØÀ'), array(1, 'öåíò', 'öåíòà', 'öåíòîâ') ), 'YUM' => array( array(1, 'þãîñëàâñêèé äèíàð', 'þãîñëàâñêèõ äèíàðà', 'þãîñëàâñêèõ äèíàðîâ'), array(1, 'ïàðà', 'ïàðà', 'ïàðà') ), 'ZAR' => array( array(1, 'ðàíä', 'ðàíäà', 'ðàíäîâ'), array(1, 'öåíò', 'öåíòà', 'öåíòîâ') ) ); /** * The default currency name * @var string * @access public */ var $def_currency = 'RUB'; // Russian rouble // }}} // {{{ _toWords() /** * Converts a number to its word representation * in Russian language * * @param integer $num An integer between -infinity and infinity inclusive :) * that need to be converted to words * @param integer $gender Gender of string, 0=neutral, 1=male, 2=female. * Optional, defaults to 1. * * @return string The corresponding word representation * * @access protected * @author Andrey Demenev * @since Numbers_Words 0.16.3 */ function _toWords($num, $options = array()) { $dummy = null; $gender = 1; /** * Loads user options */ extract($options, EXTR_IF_EXISTS); return $this->_toWordsWithCase($num, $dummy, $gender); } /** * Converts a number to its word representation * in Russian language and determines the case of string. * * @param integer $num An integer between -infinity and infinity inclusive :) * that need to be converted to words * @param integer &$case A variable passed by reference which is set to case * of the word associated with the number * @param integer $gender Gender of string, 0=neutral, 1=male, 2=female. * Optional, defaults to 1. * * @return string The corresponding word representation * * @access private * @author Andrey Demenev */ function _toWordsWithCase($num, &$case, $gender = 1) { $ret = ''; $case = 3; $num = trim($num); $sign = ""; if (substr($num, 0, 1) == '-') { $sign = $this->_minus . $this->_sep; $num = substr($num, 1); } while (strlen($num) % 3) { $num = '0' . $num; } if ($num == 0 || $num == '') { $ret .= $this->_digits[$gender][0]; } else { $power = 0; while ($power < strlen($num)) { if (!$power) { $groupgender = $gender; } elseif ($power == 3) { $groupgender = 2; } else { $groupgender = 1; } $group = $this->_groupToWords(substr($num, -$power-3, 3), $groupgender, $_case); if (!$power) { $case = $_case; } if ($power == 3) { if ($_case == 1) { $group .= $this->_sep . 'òûñÿ÷à'; } elseif ($_case == 2) { $group .= $this->_sep . 'òûñÿ÷è'; } else { $group .= $this->_sep . 'òûñÿ÷'; } } elseif ($group && $power>3 && isset($this->_exponent[$power])) { $group .= $this->_sep . $this->_exponent[$power]; if ($_case == 2) { $group .= 'à'; } elseif ($_case == 3) { $group .= 'îâ'; } } if ($group) { $ret = $group . $this->_sep . $ret; } $power += 3; } } return $sign . $ret; } // }}} // {{{ _groupToWords() /** * Converts a group of 3 digits to its word representation * in Russian language. * * @param integer $num An integer between -infinity and infinity inclusive :) * that need to be converted to words * @param integer $gender Gender of string, 0=neutral, 1=male, 2=female. * @param integer &$case A variable passed by reference which is set to case * of the word associated with the number * * @return string The corresponding word representation * * @access private * @author Andrey Demenev */ function _groupToWords($num, $gender, &$case) { $ret = ''; $case = 3; if ((int)$num == 0) { $ret = ''; } elseif ($num < 10) { $ret = $this->_digits[$gender][(int)$num]; if ($num == 1) { $case = 1; } elseif ($num < 5) { $case = 2; } else { $case = 3; } } else { $num = str_pad($num, 3, '0', STR_PAD_LEFT); $hundreds = (int)$num{0}; if ($hundreds) { $ret = $this->_hundreds[$hundreds]; if (substr($num, 1) != '00') { $ret .= $this->_sep; } $case = 3; } $tens = (int)$num{1}; $ones = (int)$num{2}; if ($tens || $ones) { if ($tens == 1 && $ones == 0) { $ret .= 'äåñÿòü'; } elseif ($tens == 1) { $ret .= $this->_teens[$ones+10]; } else { if ($tens > 0) { $ret .= $this->_tens[(int)$tens]; } if ($ones > 0) { $ret .= $this->_sep . $this->_digits[$gender][$ones]; if ($ones == 1) { $case = 1; } elseif ($ones < 5) { $case = 2; } else { $case = 3; } } } } } return $ret; } // }}} // {{{ toCurrencyWords() /** * Converts a currency value to its word representation * (with monetary units) in Russian language * * @param integer $int_curr An international currency symbol * as defined by the ISO 4217 standard (three characters) * @param integer $decimal A money total amount without fraction part (e.g. amount of dollars) * @param integer $fraction Fractional part of the money amount (e.g. amount of cents) * Optional. Defaults to false. * @param integer $convert_fraction Convert fraction to words (left as numeric if set to false). * Optional. Defaults to true. * * @return string The corresponding word representation for the currency * * @access public * @author Andrey Demenev */ function toCurrencyWords($int_curr, $decimal, $fraction = false, $convert_fraction = true) { $int_curr = strtoupper($int_curr); if (!isset($this->_currency_names[$int_curr])) { $int_curr = $this->def_currency; } $curr_names = $this->_currency_names[$int_curr]; $ret = trim($this->_toWordsWithCase($decimal, $case, $curr_names[0][0])); $ret .= $this->_sep . $curr_names[0][$case]; if ($fraction !== false) { if ($convert_fraction) { $ret .= $this->_sep . trim($this->_toWordsWithCase($fraction, $case, $curr_names[1][0])); } else { $ret .= $this->_sep . $fraction; } $ret .= $this->_sep . $curr_names[1][$case]; } return $ret; } // }}} } Numbers_Words-0.16.4/Numbers/Words/lang.sv.php0000644000076500007650000002103511732225114017660 0ustar igorigor * @author Robin Ericsson * @license PHP 3.01 http://www.php.net/license/3_01.txt * @version SVN: $Id$ * @link http://pear.php.net/package/Numbers_Words */ /** * * Class for translating numbers into Swedish. * @author Robin Ericsson * @package Numbers_Words */ /** * Include needed files */ require_once "Numbers/Words.php"; /** * Class for translating numbers into Swedish. * * @category Numbers * @package Numbers_Words * @author Piotr Klaban * @author Robin Ericsson * @license PHP 3.01 http://www.php.net/license/3_01.txt * @link http://pear.php.net/package/Numbers_Words */ class Numbers_Words_sv extends Numbers_Words { // {{{ properties /** * Locale name * @var string * @access public */ var $locale = 'sv'; /** * Language name in English * @var string * @access public */ var $lang = 'Swedish'; /** * Native language name * @var string * @access public */ var $lang_native = 'Svenska'; /** * The word for the minus sign * @var string * @access private */ var $_minus = 'Minus'; // minus sign /** * The sufixes for exponents (singular and plural) * @var array * @access private */ var $_exponent = array( 0 => array(''), 3 => array('tusen', 'tusen'), 6 => array('miljon','miljoner'), 9 => array('miljard','miljarder'), 12 => array('biljon','biljoner'), 15 => array('biljard','biljarder'), 18 => array('triljon','triljoner'), 21 => array('triljard','triljarder'), 24 => array('kvadriljon','kvadriljoner'), 27 => array('kvadriljard','kvadriljarder'), 30 => array('kvintiljon','kvintiljoner'), 33 => array('kvintiljard','kvintiljarder'), 36 => array('sextiljon','sextiljoner'), 39 => array('sextiljard','sextiljarder'), 42 => array('septiljon','septiljoner'), 45 => array('septiljard','septiljarder'), 48 => array('oktiljon','oktiljoner'), 51 => array('oktiljard','oktiljarder'), 54 => array('noniljon','noniljoner'), 57 => array('noniljard','noniljarder'), 60 => array('dekiljon','dekiljoner'), 63 => array('dekiljard','dekiljarder'), 120 => array('vigintiljon','vigintiljoner'), 123 => array('vigintiljard','vigintiljarder'), 600 => array('centiljon','centiljoner'), 603 => array('centiljard','centiljarder') ); /** * The array containing the digits (indexed by the digits themselves). * @var array * @access private */ var $_digits = array( 0 => 'noll', 'ett', 'två', 'tre', 'fyra', 'fem', 'sex', 'sju', 'åtta', 'nio' ); /** * The word separator * @var string * @access private */ var $_sep = ''; /** * The exponent word separator * @var string * @access private */ var $_sep2 = ' '; // }}} // {{{ _toWords() /** * Converts a number to its word representation * in Swedish language. * * @param integer $num An integer between -infinity and infinity inclusive :) * that need to be converted to words * @param integer $power The power of ten for the rest of the number to the right. * Optional, defaults to 0. * @param integer $powsuffix The power name to be added to the end of the return string. * Used internally. Optional, defaults to ''. * * @return string The corresponding word representation * * @access protected * @author Piotr Klaban * @author Robin Ericsson * @since Numbers_Words 0.16.3 */ function _toWords($num, $power = 0, $powsuffix = '') { $ret = ''; // add a minus sign if (substr($num, 0, 1) == '-') { $ret = $this->_sep . $this->_minus; $num = substr($num, 1); } // strip excessive zero signs and spaces $num = trim($num); $num = preg_replace('/^0+/', '', $num); if (strlen($num) > 3) { $maxp = strlen($num)-1; $curp = $maxp; for ($p = $maxp; $p > 0; --$p) { // power // check for highest power if (isset($this->_exponent[$p])) { // send substr from $curp to $p $snum = substr($num, $maxp - $curp, $curp - $p + 1); $snum = preg_replace('/^0+/', '', $snum); if ($snum !== '') { $cursuffix = $this->_exponent[$power][count($this->_exponent[$power])-1]; if ($powsuffix != '') { $cursuffix .= $this->_sep . $powsuffix; } $ret .= $this->_toWords($snum, $p, $cursuffix); } $curp = $p - 1; continue; } } $num = substr($num, $maxp - $curp, $curp - $p + 1); if ($num == 0) { return $ret; } } elseif ($num == 0 || $num == '') { return $this->_sep . $this->_digits[0]; } $h = $t = $d = 0; switch(strlen($num)) { case 3: $h = (int)substr($num, -3, 1); case 2: $t = (int)substr($num, -2, 1); case 1: $d = (int)substr($num, -1, 1); break; case 0: return; break; } if ($h) { $ret .= $this->_sep . $this->_digits[$h] . $this->_sep . 'hundra'; } // ten, twenty etc. switch ($t) { case 5: case 6: case 7: $ret .= $this->_sep . $this->_digits[$t] . 'tio'; break; case 9: $ret .= $this->_sep . 'nittio'; break; case 8: $ret .= $this->_sep . 'åttio'; break; case 4: $ret .= $this->_sep . 'fyrtio'; break; case 3: $ret .= $this->_sep . 'trettio'; break; case 2: $ret .= $this->_sep . 'tjugo'; break; case 1: switch ($d) { case 0: $ret .= $this->_sep . 'tio'; break; case 1: $ret .= $this->_sep . 'elva'; break; case 2: $ret .= $this->_sep . 'tolv'; break; case 3: $ret .= $this->_sep . 'tretton'; break; case 4: $ret .= $this->_sep . 'fjorton'; break; case 5: case 6: $ret .= $this->_sep . $this->_digits[$d] . 'ton'; break; case 7: $ret .= $this->_sep . 'sjutton'; break; case 8: $ret .= $this->_sep . 'arton'; break; case 9: $ret .= $this->_sep . 'nitton'; } break; } if ($t != 1 && $d > 0) { // add digits only in <0>,<1,9> and <21,inf> // add minus sign between [2-9] and digit $ret .= $this->_sep . $this->_digits[$d]; } if ($power > 0) { if (isset($this->_exponent[$power])) { $lev = $this->_exponent[$power]; } if (!isset($lev) || !is_array($lev)) { return null; } $ret .= $this->_sep . $lev[0]; } if ($powsuffix != '') { $ret .= $this->_sep . $powsuffix; } return $ret; } // }}} } Numbers_Words-0.16.4/Numbers/Words/lang.tr_TR.php0000644000076500007650000002766311732225114020277 0ustar igorigor * @package Numbers_Words */ /** * Include needed files */ require_once('Numbers/Words.php'); /** * Class for translating numbers into Italian. * It supports up to quadrilions * * @author Shahriyar Imanov * @package Numbers_Words */ class Numbers_Words_tr_TR extends Numbers_Words { // {{{ properties /** * Locale name * @var string * @access public */ var $locale = 'tr_TR'; /** * Language name in English * @var string * @access public */ var $lang = 'Turkish'; /** * Native language name * @var string * @access public */ var $lang_native = 'Türkçe'; /** * The word for the minus sign * @var string * @access private */ var $_minus = 'eksi'; /** * The sufixes for exponents (singular and plural) * @var array * @access private */ var $_exponent = array( 0 => array(''), 3 => array('bin'), 6 => array('milyon'), 12 => array('milyar'), 18 => array('trilyon'), 24 => array('katrilyon'), ); /** * The array containing the digits (indexed by the digits themselves). * @var array * @access private */ var $_digits = array( 0 => 's?f?r', 'bir', 'iki', 'üç', 'dört', 'be?', 'alt?', 'yedi', 'sekiz', 'dokuz' ); /** * The word separator * @var string * @access private */ var $_sep = ' '; /** * The currency names (based on the below links, * informations from central bank websites and on encyclopedias) * * @var array * @link http://30-03-67.dreamstation.com/currency_alfa.htm World Currency Information * @link http://www.jhall.demon.co.uk/currency/by_abbrev.html World currencies * @link http://www.shoestring.co.kr/world/p.visa/change.htm Currency names in English * @access private */ var $_currency_names = array( 'ALL' => array(array('lek'), array('qindarka')), 'AUD' => array(array('Avusturalya dolar?'), array('sent')), 'BAM' => array(array('convertible marka'), array('fenig')), 'BGN' => array(array('Bulgar levas?'), array('stotinka','stotinki')), 'BRL' => array(array('real'), array('centavos')), 'BWP' => array(array('Botswana pulas?'), array('thebe')), 'BYR' => array(array('Belarus rublesi'), array('kopiejka')), 'CAD' => array(array('Kanada dolar?'), array('sent')), 'CHF' => array(array('?sveç frank?'), array('rapp')), 'CHF' => array(array('Çin yuan?'), array('fen')), 'CYP' => array(array('K?br?s pound\'u'), array('sent')), 'CZK' => array(array('Çek kronu'), array('halerz')), 'DKK' => array(array('Danmarka kronu'), array('ore')), 'EEK' => array(array('kroon'), array('senti')), 'EUR' => array(array('Avro'), array('Avro-sent')), 'GBP' => array(array('pound', 'pound'), array('pence', 'pence')), 'HKD' => array(array('Hong Kong dolar?'), array('sent')), 'HRK' => array(array('H?rvatistan kunas?'), array('lipa')), 'HUF' => array(array('Macar forinti'), array('filler')), 'ILS' => array(array('yeni sheqel','yeni sheqels'), array('agora','agorot')), 'ISK' => array(array('Izlanda kronu'), array('aurar')), 'JPY' => array(array('Japon yeni'), array('sen')), 'LTL' => array(array('Litvanya litas?'), array('sent')), 'LVL' => array(array('Letonya lat?'), array('sentim')), 'MKD' => array(array('Makedonya dinar?'), array('deni')), 'MTL' => array(array('Malta liras?'), array('centym')), 'NOK' => array(array('Norveç kronu'), array('oere')), 'PLN' => array(array('zloty', 'zlotys'), array('grosz')), 'ROL' => array(array('Romanya leu'), array('bani')), 'RUB' => array(array('Ruble'), array('kopiejka')), 'SEK' => array(array('?sveç kronu'), array('oere')), 'SIT' => array(array('Tolar'), array('stotinia')), 'SKK' => array(array('Slovakya kronu'), array()), 'TRY' => array(array('Türk Liras?'), array('kuru?')), 'UAH' => array(array('Ukrayna hryvnyas?'), array('kopiyka')), 'USD' => array(array('ABD Dolar?'), array('sent')), 'YUM' => array(array('dinar'), array('para')), 'ZAR' => array(array('Güney Afrika rand?'), array('sent')) ); /** * The default currency name * @var string * @access public */ var $def_currency = 'TRY'; // Türk Liras? // }}} // {{{ _toWords() /** * Converts a number to its word representation * in italiano. * * @param integer $num An integer between -infinity and infinity inclusive :) * that should be converted to a words representation * @param integer $power The power of ten for the rest of the number to the right. * For example toWords(12,3) should give "doce mil". * Optional, defaults to 0. * @return string The corresponding word representation * * @access protected * @author Filippo Beltramini * @since Numbers_Words 0.16.3 */ function _toWords($num, $power = 0) { // The return string; $ret = ''; // add a the word for the minus sign if necessary if (substr($num, 0, 1) == '-') { $ret = $this->_sep . $this->_minus; $num = substr($num, 1); } // strip excessive zero signs $num = preg_replace('/^0+/','',$num); if (strlen($num) > 6) { $current_power = 6; // check for highest power if (isset($this->_exponent[$power])) { // convert the number above the first 6 digits // with it's corresponding $power. $snum = substr($num, 0, -6); $snum = preg_replace('/^0+/','',$snum); if ($snum !== '') { $ret .= $this->_toWords($snum, $power + 6); } } $num = substr($num, -6); if ($num == 0) { return $ret; } } elseif ($num == 0 || $num == '') { return(' '.$this->_digits[0].' '); $current_power = strlen($num); } else { $current_power = strlen($num); } // See if we need "thousands" $thousands = floor($num / 1000); if ($thousands == 1) { $ret .= $this->_sep . 'bin' . $this->_sep; } elseif ($thousands > 1) { $ret .= $this->_toWords($thousands, 3) . $this->_sep;//. 'mil' . $this->_sep; } // values for digits, tens and hundreds $h = floor(($num / 100) % 10); $t = floor(($num / 10) % 10); $d = floor($num % 10); if ($h) { $ret .= $this->_sep . $this->_digits[$h] . $this->_sep . 'yüz'; // in English only - add ' and' for [1-9]01..[1-9]99 // (also for 1001..1099, 10001..10099 but it is harder) // for now it is switched off, maybe some language purists // can force me to enable it, or to remove it completely // if (($t + $d) > 0) // $ret .= $this->_sep . 'and'; } // decine: venti trenta, etc... switch ($t) { case 9: $ret .= $this->_sep . 'doksan'; break; case 8: $ret .= $this->_sep . 'seksen'; break; case 7: $ret .= $this->_sep . 'yetmi?'; break; case 6: $ret .= $this->_sep . 'altm??'; break; case 5: $ret .= $this->_sep . 'elli'; break; case 4: $ret .= $this->_sep . 'k?rk'; break; case 3: $ret .= $this->_sep . 'otuz'; break; case 2: $ret .= $this->_sep . 'yirmi'; break; case 2: $ret .= $this->_sep . 'on'; break; break; } if ($t > 1 && $d > 0) { $ret .= $this->_sep . $this->_digits[$d]; } if ($power > 0) { if (isset($this->_exponent[$power])) { $lev = $this->_exponent[$power]; } if (!isset($lev) || !is_array($lev)) { return null; } // if it's only one use the singular suffix if (($d == 1) and ($t == 0) and ($h == 0)) { $suffix = $lev[0]; } else { $suffix = $lev[1]; } if ($num != 0) { $ret .= $this->_sep . $suffix; } } return $ret; } // }}} // {{{ toCurrencyWords() /** * Converts a currency value to its word representation * (with monetary units) in English language * * @param integer $int_curr An international currency symbol * as defined by the ISO 4217 standard (three characters) * @param integer $decimal A money total amount without fraction part (e.g. amount of dollars) * @param integer $fraction Fractional part of the money amount (e.g. amount of cents) * Optional. Defaults to false. * @param integer $convert_fraction Convert fraction to words (left as numeric if set to false). * Optional. Defaults to true. * * @return string The corresponding word representation for the currency * * @access public * @author Piotr Klaban * @since Numbers_Words 0.4 */ function toCurrencyWords($int_curr, $decimal, $fraction = false, $convert_fraction = true) { $int_curr = strtoupper($int_curr); if (!isset($this->_currency_names[$int_curr])) { $int_curr = $this->def_currency; } $curr_names = $this->_currency_names[$int_curr]; $ret = trim($this->_toWords($decimal)); $lev = ($decimal == 1) ? 0 : 1; if ($lev > 0) { if (count($curr_names[0]) > 1) { $ret .= $this->_sep . $curr_names[0][$lev]; } else { $ret .= $this->_sep . $curr_names[0][0]; } } else { $ret .= $this->_sep . $curr_names[0][0]; } if ($fraction !== false) { if ($convert_fraction) { $ret .= $this->_sep . trim($this->_toWords($fraction)); } else { $ret .= $this->_sep . $fraction; } $lev = ($fraction == 1) ? 0 : 1; if ($lev > 0) { if (count($curr_names[1]) > 1) { $ret .= $this->_sep . $curr_names[1][$lev]; } else { $ret .= $this->_sep . $curr_names[1][0] . 's'; } } else { $ret .= $this->_sep . $curr_names[1][0]; } } return $ret; } // }}} } Numbers_Words-0.16.4/tests/AllTests.php0000644000076500007650000000544511732225114016503 0ustar igorigoraddTestSuite('Numbers_Words_BulgarianTest'); $suite->addTestSuite('Numbers_Words_English100Test'); $suite->addTestSuite('Numbers_Words_EnglishGbTest'); $suite->addTestSuite('Numbers_Words_EnglishUsTest'); $suite->addTestSuite('Numbers_Words_FrenchTest'); $suite->addTestSuite('Numbers_Words_FrenchBeTest'); $suite->addTestSuite('Numbers_Words_GermanTest'); $suite->addTestSuite('Numbers_Words_ItalianTest'); $suite->addTestSuite('Numbers_Words_PolishTest'); $suite->addTestSuite('Numbers_Words_PortugueseBrazilianTest'); $suite->addTestSuite('Numbers_Words_SpanishTest'); $suite->addTestSuite('Numbers_Words_HungarianTest'); return $suite; } } if (PHPUnit_MAIN_METHOD == 'Numbers_Words_AllTests::main') { Numbers_Words_AllTests::main(); } Numbers_Words-0.16.4/tests/BulgarianTest.php0000644000076500007650000001334111732225114017506 0ustar igorigorhandle = new Numbers_Words(); } /** * Testing numbers between 0 and 9 */ function testDigits() { $digits = array('íóëà', 'åäíî', 'äâå', 'òðè', '÷åòèðè', 'ïåò', 'øåñò', 'ñåäåì', 'îñåì', 'äåâåò' ); for ($i = 0; $i < 10; $i++) { $number = $this->handle->toWords($i, 'bg'); $this->assertEquals($digits[$i], $number); } } /** * Testing numbers between 10 and 99 */ function testTens() { $tens = array(11 => 'åäèíàäåñåò', 12 => 'äâàíàäåñåò', 16 => 'øåñòíàäåñåò', 19 => 'äåâåòíàäåñåò', 20 => 'äâàäåñåò', 21 => 'äâàäåñåò è åäíî', 26 => 'äâàäåñåò è øåñò', 30 => 'òðèäåñåò', 31 => 'òðèäåñåò è åäíî', 40 => '÷åòèðèäåñåò', 43 => '÷åòèðèäåñåò è òðè', 50 => 'ïåòäåñåò', 55 => 'ïåòäåñåò è ïåò', 60 => 'øåñòäåñåò', 67 => 'øåñòäåñåò è ñåäåì', 70 => 'ñåäåìäåñåò', 79 => 'ñåäåìäåñåò è äåâåò' ); foreach ($tens as $number => $word) { $this->assertEquals($word, $this->handle->toWords($number, 'bg')); } } /** * Testing numbers between 100 and 999 */ function testHundreds() { $hundreds = array(100 => 'ñòî', 101 => 'ñòî è åäíî', 199 => 'ñòî äåâåòäåñåò è äåâåò', 203 => 'äâåñòà è òðè', 287 => 'äâåñòà îñåìäåñåò è ñåäåì', 300 => 'òðèñòà', 356 => 'òðèñòà ïåòäåñåò è øåñò', 410 => '÷åòèðèñòîòèí è äåñåò', 434 => '÷åòèðèñòîòèí òðèäåñåò è ÷åòèðè', 578 => 'ïåòñòîòèí ñåäåìäåñåò è îñåì', 689 => 'øåñòñòîòèí îñåìäåñåò è äåâåò', 729 => 'ñåäåìñòîòèí äâàäåñåò è äåâåò', 894 => 'îñåìñòîòèí äåâåòäåñåò è ÷åòèðè', 999 => 'äåâåòñòîòèí äåâåòäåñåò è äåâåò' ); foreach ($hundreds as $number => $word) { $this->assertEquals($word, $this->handle->toWords($number, 'bg')); } } /** * Testing numbers between 1000 and 9999 */ function testThousands() { $thousands = array(1000 => 'õèëÿäà', 1001 => 'õèëÿäà è åäíî', 1097 => 'õèëÿäà è äåâåòäåñåò è ñåäåì', 1104 => 'õèëÿäà ñòî è ÷åòèðè', 1243 => 'õèëÿäà äâåñòà ÷åòèðèäåñåò è òðè', 2385 => 'äâå õèëÿäè òðèñòà îñåìäåñåò è ïåò', 3766 => 'òðè õèëÿäè ñåäåìñòîòèí øåñòäåñåò è øåñò', 4196 => '÷åòèðè õèëÿäè ñòî äåâåòäåñåò è øåñò', 5846 => 'ïåò õèëÿäè îñåìñòîòèí ÷åòèðèäåñåò è øåñò', 6459 => 'øåñò õèëÿäè ÷åòèðèñòîòèí ïåòäåñåò è äåâåò', 7232 => 'ñåäåì õèëÿäè äâåñòà òðèäåñåò è äâå', 8569 => 'îñåì õèëÿäè ïåòñòîòèí øåñòäåñåò è äåâåò', 9539 => 'äåâåò õèëÿäè ïåòñòîòèí òðèäåñåò è äåâåò' ); foreach ($thousands as $number => $word) { $this->assertEquals($word, $this->handle->toWords($number, 'bg')); } } } if (PHPUnit_MAIN_METHOD == 'Numbers_Words_BulgarianTest::main') { Numbers_Words_BulgarianTest::main(); } Numbers_Words-0.16.4/tests/English100Test.php0000755000076500007650000001427411732225114017425 0ustar igorigorhandle = new Numbers_Words(); } /** * Testing numbers between 0 and 9 */ function testDigits() { $digits = array('zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine' ); for ($i = 0; $i < 10; $i++) { $number = $this->handle->toWords($i, $this->lang); $this->assertEquals($digits[$i], $number); } } /** * Testing numbers between 10 and 99 */ function testTens() { $tens = array(11 => 'eleven', 12 => 'twelve', 16 => 'sixteen', 19 => 'nineteen', 20 => 'twenty', 21 => 'twenty-one', 26 => 'twenty-six', 30 => 'thirty', 31 => 'thirty-one', 40 => 'forty', 43 => 'forty-three', 50 => 'fifty', 55 => 'fifty-five', 60 => 'sixty', 67 => 'sixty-seven', 70 => 'seventy', 79 => 'seventy-nine' ); foreach ($tens as $number => $word) { $this->assertEquals($word, $this->handle->toWords($number, $this->lang)); } } /** * Testing numbers between 100 and 999 */ function testHundreds() { $hundreds = array(100 => 'one hundred', 101 => 'one hundred one', 199 => 'one hundred ninety-nine', 203 => 'two hundred three', 287 => 'two hundred eighty-seven', 300 => 'three hundred', 356 => 'three hundred fifty-six', 410 => 'four hundred ten', 434 => 'four hundred thirty-four', 578 => 'five hundred seventy-eight', 689 => 'six hundred eighty-nine', 729 => 'seven hundred twenty-nine', 894 => 'eight hundred ninety-four', 999 => 'nine hundred ninety-nine' ); foreach ($hundreds as $number => $word) { $this->assertEquals($word, $this->handle->toWords($number, $this->lang)); } } /** * Testing numbers between 1000 and 9999 */ function testThousands() { $thousands = array(1000 => 'ten hundred', 1001 => 'ten hundred one', 1097 => 'ten hundred ninety-seven', 1104 => 'eleven hundred four', 1243 => 'twelve hundred forty-three', 2385 => 'twenty-three hundred eighty-five', 3766 => 'thirty-seven hundred sixty-six', 4196 => 'forty-one hundred ninety-six', 5846 => 'fifty-eight hundred forty-six', 6459 => 'sixty-four hundred fifty-nine', 7232 => 'seventy-two hundred thirty-two', 8569 => 'eighty-five hundred sixty-nine', 9539 => 'ninety-five hundred thirty-nine' ); foreach ($thousands as $number => $word) { $this->assertEquals($word, $this->handle->toWords($number, $this->lang)); } } /** * Test *yllions and *ylliards */ function testMore() { $morers = array( 50000 => 'five myriad', 600000 => 'sixty myriad', 7000000 => 'seven hundred myriad', 80000000 => 'eighty hundred myriad', 900000000 => 'nine myllion', 1000000000 => 'ten myllion' ); foreach ($morers as $number => $word) { $this->assertEquals($word, $this->handle->toWords($number, $this->lang)); } } } if (PHPUnit_MAIN_METHOD == 'Numbers_Words_English100Test::main') { Numbers_Words_English100Test::main(); } Numbers_Words-0.16.4/tests/EnglishGbTest.php0000755000076500007650000001416411732225114017453 0ustar igorigor * @copyright 1997-2008 The PHP Group * @license http://www.php.net/license/3_01.txt PHP License 3.01 * @version SVN: $Id$ * @link http://pear.php.net/package/Numbers_Words */ if (!defined('PHPUnit_MAIN_METHOD')) { define('PHPUnit_MAIN_METHOD', 'Numbers_Words_EnglishGbTest::main'); } require_once 'Numbers/Words.php'; require_once 'PHPUnit/Framework/TestCase.php'; class Numbers_Words_EnglishGbTest extends PHPUnit_Framework_TestCase { var $handle; var $lang = 'en_GB'; public static function main() { require_once 'PHPUnit/TextUI/TestRunner.php'; PHPUnit_TextUI_TestRunner::run( new PHPUnit_Framework_TestSuite('Numbers_Words_EnglishGbTest') ); } function setUp() { $this->handle = new Numbers_Words(); } /** * Testing numbers between 0 and 9 */ function testDigits() { $digits = array('zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine' ); for ($i = 0; $i < 10; $i++) { $number = $this->handle->toWords($i, $this->lang); $this->assertEquals($digits[$i], $number); } } /** * Testing numbers between 10 and 99 */ function testTens() { $tens = array(11 => 'eleven', 12 => 'twelve', 16 => 'sixteen', 19 => 'nineteen', 20 => 'twenty', 21 => 'twenty-one', 26 => 'twenty-six', 30 => 'thirty', 31 => 'thirty-one', 40 => 'forty', 43 => 'forty-three', 50 => 'fifty', 55 => 'fifty-five', 60 => 'sixty', 67 => 'sixty-seven', 70 => 'seventy', 79 => 'seventy-nine' ); foreach ($tens as $number => $word) { $this->assertEquals($word, $this->handle->toWords($number, $this->lang)); } } /** * Testing numbers between 100 and 999 */ function testHundreds() { $hundreds = array(100 => 'one hundred', 101 => 'one hundred one', 199 => 'one hundred ninety-nine', 203 => 'two hundred three', 287 => 'two hundred eighty-seven', 300 => 'three hundred', 356 => 'three hundred fifty-six', 410 => 'four hundred ten', 434 => 'four hundred thirty-four', 578 => 'five hundred seventy-eight', 689 => 'six hundred eighty-nine', 729 => 'seven hundred twenty-nine', 894 => 'eight hundred ninety-four', 999 => 'nine hundred ninety-nine' ); foreach ($hundreds as $number => $word) { $this->assertEquals($word, $this->handle->toWords($number, $this->lang)); } } /** * Testing numbers between 1000 and 9999 */ function testThousands() { $thousands = array(1000 => 'one thousand', 1001 => 'one thousand one', 1097 => 'one thousand ninety-seven', 1104 => 'one thousand one hundred four', 1243 => 'one thousand two hundred forty-three', 2385 => 'two thousand three hundred eighty-five', 3766 => 'three thousand seven hundred sixty-six', 4196 => 'four thousand one hundred ninety-six', 5846 => 'five thousand eight hundred forty-six', 6459 => 'six thousand four hundred fifty-nine', 7232 => 'seven thousand two hundred thirty-two', 8569 => 'eight thousand five hundred sixty-nine', 9539 => 'nine thousand five hundred thirty-nine' ); foreach ($thousands as $number => $word) { $this->assertEquals($word, $this->handle->toWords($number, $this->lang)); } } /** * en_GB (old version) and en_US differentiate in their millions/billions/trillions * because en_GB once used the long scale, and en_US the short scale. * GB abandoned the long scale in 1974, though. * * Numbers_Words still provides the long scale. Use en_US to get short scaled numbers. */ function testMore() { $this->assertEquals('one million', $this->handle->toWords(1000000, $this->lang)); $this->assertEquals('two thousand million', $this->handle->toWords(2000000000, $this->lang)); // 32 bit systems vs PHP_INT_SIZE - 3 billion is a little high, so use a string version. $number = '3000000000000' > PHP_INT_SIZE? '3000000000000' : 3000000000000; $this->assertEquals('three billion', $this->handle->toWords($number, $this->lang)); } } if (PHPUnit_MAIN_METHOD == 'Numbers_Words_EnglishGbTest::main') { Numbers_Words_EnglishGbTest::main(); } Numbers_Words-0.16.4/tests/EnglishUsTest.php0000755000076500007650000001466311732225114017516 0ustar igorigorhandle = new Numbers_Words(); } /** * Testing numbers between 0 and 9 */ function testDigits() { $digits = array('zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine' ); for ($i = 0; $i < 10; $i++) { $number = $this->handle->toWords($i, $this->lang); $this->assertEquals($digits[$i], $number); } } /** * Testing numbers between 10 and 99 */ function testTens() { $tens = array(11 => 'eleven', 12 => 'twelve', 16 => 'sixteen', 19 => 'nineteen', 20 => 'twenty', 21 => 'twenty-one', 26 => 'twenty-six', 30 => 'thirty', 31 => 'thirty-one', 40 => 'forty', 43 => 'forty-three', 50 => 'fifty', 55 => 'fifty-five', 60 => 'sixty', 67 => 'sixty-seven', 70 => 'seventy', 79 => 'seventy-nine' ); foreach ($tens as $number => $word) { $this->assertEquals($word, $this->handle->toWords($number, $this->lang)); } } /** * Testing numbers between 100 and 999 */ function testHundreds() { $hundreds = array(100 => 'one hundred', 101 => 'one hundred one', 199 => 'one hundred ninety-nine', 203 => 'two hundred three', 287 => 'two hundred eighty-seven', 300 => 'three hundred', 356 => 'three hundred fifty-six', 410 => 'four hundred ten', 434 => 'four hundred thirty-four', 578 => 'five hundred seventy-eight', 689 => 'six hundred eighty-nine', 729 => 'seven hundred twenty-nine', 894 => 'eight hundred ninety-four', 999 => 'nine hundred ninety-nine' ); foreach ($hundreds as $number => $word) { $this->assertEquals($word, $this->handle->toWords($number, $this->lang)); } } /** * Testing numbers between 1000 and 9999 */ function testThousands() { $thousands = array(1000 => 'one thousand', 1001 => 'one thousand one', 1097 => 'one thousand ninety-seven', 1104 => 'one thousand one hundred four', 1243 => 'one thousand two hundred forty-three', 2385 => 'two thousand three hundred eighty-five', 3766 => 'three thousand seven hundred sixty-six', 4196 => 'four thousand one hundred ninety-six', 5846 => 'five thousand eight hundred forty-six', 6459 => 'six thousand four hundred fifty-nine', 7232 => 'seven thousand two hundred thirty-two', 8569 => 'eight thousand five hundred sixty-nine', 9539 => 'nine thousand five hundred thirty-nine' ); foreach ($thousands as $number => $word) { $this->assertEquals($word, $this->handle->toWords($number, $this->lang)); } } /** * en_GB (old version) and en_US differentiate in their millions/billions/trillions * because en_GB once used the long scale, and en_US the short scale. * * We're testing the short scale here. */ function testMore() { $this->assertEquals('one million', $this->handle->toWords(1000000, $this->lang)); $this->assertEquals('two billion', $this->handle->toWords(2000000000, $this->lang)); // 32 bit systems vs PHP_INT_SIZE - 3 trillion is a little high, so use a string version. $number = '3000000000000' > PHP_INT_SIZE? '3000000000000' : 3000000000000; $this->assertEquals('three trillion', $this->handle->toWords($number, $this->lang)); } } if (PHPUnit_MAIN_METHOD == 'Numbers_Words_EnglishUsTest::main') { Numbers_Words_EnglishUsTest::main(); } Numbers_Words-0.16.4/tests/FrenchBeTest.php0000644000076500007650000001253511732225114017262 0ustar igorigor * @copyright 1997-2008 The PHP Group * @license http://www.php.net/license/3_01.txt PHP License 3.01 * @version SVN: $Id$ * @link http://pear.php.net/package/Numbers_Words */ if (!defined('PHPUnit_MAIN_METHOD')) { define('PHPUnit_MAIN_METHOD', 'Numbers_Words_FrenchBeTest::main'); } require_once 'Numbers/Words.php'; require_once 'PHPUnit/Framework/TestCase.php'; class Numbers_Words_FrenchBeTest extends PHPUnit_Framework_TestCase { var $handle; public static function main() { require_once 'PHPUnit/TextUI/TestRunner.php'; PHPUnit_TextUI_TestRunner::run( new PHPUnit_Framework_TestSuite('Numbers_Words_FrenchBeTest') ); } function setUp() { $this->handle = new Numbers_Words(); } /** * Testing numbers between 0 and 9 */ function testDigits() { $digits = array('zéro', 'un', 'deux', 'trois', 'quatre', 'cinq', 'six', 'sept', 'huit', 'neuf' ); for ($i = 0; $i < 10; $i++) { $number = $this->handle->toWords($i, 'fr_BE'); $this->assertEquals($digits[$i], $number); } } /** * Testing numbers between 10 and 99 */ function testTens() { $tens = array(11 => 'onze', 12 => 'douze', 16 => 'seize', 19 => 'dix-neuf', 20 => 'vingt', 21 => 'vingt et un', 26 => 'vingt-six', 30 => 'trente', 31 => 'trente et un', 40 => 'quarante', 43 => 'quarante-trois', 50 => 'cinquante', 55 => 'cinquante-cinq', 60 => 'soixante', 67 => 'soixante-sept', 70 => 'septante', 71 => 'septante et un', 79 => 'septante-neuf', 80 => 'quatre-vingts', 81 => 'quatre-vingt-un', 91 => 'nonante et un' ); foreach ($tens as $number => $word) { $this->assertEquals($word, $this->handle->toWords($number, 'fr_BE')); } } /** * Testing numbers between 100 and 999 */ function testHundreds() { $hundreds = array(100 => 'cent', 101 => 'cent un', 199 => 'cent nonante-neuf', 203 => 'deux cent trois', 287 => 'deux cent quatre-vingt-sept', 300 => 'trois cents', 356 => 'trois cent cinquante-six', 410 => 'quatre cent dix', 434 => 'quatre cent trente-quatre', 578 => 'cinq cent septante-huit', 689 => 'six cent quatre-vingt-neuf', 729 => 'sept cent vingt-neuf', 894 => 'huit cent nonante-quatre', 999 => 'neuf cent nonante-neuf' ); foreach ($hundreds as $number => $word) { $this->assertEquals($word, $this->handle->toWords($number, 'fr_BE')); } } /** * Testing numbers between 1000 and 9999 */ function testThousands() { $thousands = array(1000 => 'mille', 1001 => 'mille un', 1097 => 'mille nonante-sept', 1104 => 'mille cent quatre', 1243 => 'mille deux cent quarante-trois', 2385 => 'deux mille trois cent quatre-vingt-cinq', 3766 => 'trois mille sept cent soixante-six', 4196 => 'quatre mille cent nonante-six', 5846 => 'cinq mille huit cent quarante-six', 6459 => 'six mille quatre cent cinquante-neuf', 7232 => 'sept mille deux cent trente-deux', 8569 => 'huit mille cinq cent soixante-neuf', 9539 => 'neuf mille cinq cent trente-neuf' ); foreach ($thousands as $number => $word) { $this->assertEquals($word, $this->handle->toWords($number, 'fr_BE')); } } } if (PHPUnit_MAIN_METHOD == 'Numbers_Words_FrenchBeTest::main') { Numbers_Words_FrenchBeTest::main(); } Numbers_Words-0.16.4/tests/FrenchTest.php0000644000076500007650000001346611732225114017017 0ustar igorigorhandle = new Numbers_Words(); } /** * Testing numbers between 0 and 9 */ function testDigits() { $digits = array('zéro', 'un', 'deux', 'trois', 'quatre', 'cinq', 'six', 'sept', 'huit', 'neuf' ); for ($i = 0; $i < 10; $i++) { $number = $this->handle->toWords($i, 'fr'); $this->assertEquals($digits[$i], $number); } } /** * Testing numbers between 10 and 99 */ function testTens() { $tens = array(11 => 'onze', 12 => 'douze', 16 => 'seize', 19 => 'dix-neuf', 20 => 'vingt', 21 => 'vingt et un', 26 => 'vingt-six', 30 => 'trente', 31 => 'trente et un', 40 => 'quarante', 43 => 'quarante-trois', 50 => 'cinquante', 55 => 'cinquante-cinq', 60 => 'soixante', 67 => 'soixante-sept', 70 => 'soixante-dix', 71 => 'soixante et onze', 79 => 'soixante-dix-neuf', 80 => 'quatre-vingts', 81 => 'quatre-vingt-un', 91 => 'quatre-vingt-onze' ); foreach ($tens as $number => $word) { $this->assertEquals($word, $this->handle->toWords($number, 'fr')); } } /** * Testing numbers between 100 and 999 */ function testHundreds() { $hundreds = array(100 => 'cent', 101 => 'cent un', 199 => 'cent quatre-vingt-dix-neuf', 203 => 'deux cent trois', 287 => 'deux cent quatre-vingt-sept', 300 => 'trois cents', 356 => 'trois cent cinquante-six', 410 => 'quatre cent dix', 434 => 'quatre cent trente-quatre', 578 => 'cinq cent soixante-dix-huit', 689 => 'six cent quatre-vingt-neuf', 729 => 'sept cent vingt-neuf', 894 => 'huit cent quatre-vingt-quatorze', 999 => 'neuf cent quatre-vingt-dix-neuf' ); foreach ($hundreds as $number => $word) { $this->assertEquals($word, $this->handle->toWords($number, 'fr')); } } /** * Testing numbers between 1000 and 9999 */ function testThousands() { $thousands = array(1000 => 'mille', 1001 => 'mille un', 1097 => 'mille quatre-vingt-dix-sept', 1104 => 'mille cent quatre', 1243 => 'mille deux cent quarante-trois', 2385 => 'deux mille trois cent quatre-vingt-cinq', 3766 => 'trois mille sept cent soixante-six', 4196 => 'quatre mille cent quatre-vingt-seize', 5846 => 'cinq mille huit cent quarante-six', 6459 => 'six mille quatre cent cinquante-neuf', 7232 => 'sept mille deux cent trente-deux', 8569 => 'huit mille cinq cent soixante-neuf', 9539 => 'neuf mille cinq cent trente-neuf' ); foreach ($thousands as $number => $word) { $this->assertEquals($word, $this->handle->toWords($number, 'fr')); } } } if (PHPUnit_MAIN_METHOD == 'Numbers_Words_FrenchTest::main') { Numbers_Words_FrenchTest::main(); } Numbers_Words-0.16.4/tests/GermanTest.php0000755000076500007650000001237611732225114017025 0ustar igorigor * @copyright 1997-2008 The PHP Group * @license http://www.php.net/license/3_01.txt PHP License 3.01 * @version SVN: $Id$ * @link http://pear.php.net/package/Numbers_Words */ if (!defined('PHPUnit_MAIN_METHOD')) { define('PHPUnit_MAIN_METHOD', 'Numbers_Words_GermanTest::main'); } require_once 'Numbers/Words.php'; require_once 'PHPUnit/Framework/TestCase.php'; class Numbers_Words_GermanTest extends PHPUnit_Framework_TestCase { var $handle; public static function main() { require_once 'PHPUnit/TextUI/TestRunner.php'; PHPUnit_TextUI_TestRunner::run( new PHPUnit_Framework_TestSuite('Numbers_Words_GermanTest') ); } function setUp() { $this->handle = new Numbers_Words(); } /** * Testing numbers between 0 and 9 */ function testDigits() { $digits = array('null', 'eins', 'zwei', 'drei', 'vier', 'fünf', 'sechs', 'sieben', 'acht', 'neun' ); for ($i = 0; $i < 10; $i++) { $number = $this->handle->toWords($i, 'de'); $this->assertEquals($digits[$i], $number); } } /** * Testing numbers between 10 and 99 */ function testTens() { $tens = array(11 => 'elf', 12 => 'zwölf', 16 => 'sechzehn', 19 => 'neunzehn', 20 => 'zwanzig', 21 => 'einundzwanzig', 26 => 'sechsundzwanzig', 30 => 'dreißig', 31 => 'einunddreißig', 40 => 'vierzig', 43 => 'dreiundvierzig', 50 => 'fünfzig', 55 => 'fünfundfünfzig', 60 => 'sechzig', 67 => 'siebenundsechzig', 70 => 'siebzig', 79 => 'neunundsiebzig' ); foreach ($tens as $number => $word) { $this->assertEquals($word, $this->handle->toWords($number, 'de')); } } /** * Testing numbers between 100 and 999 */ function testHundreds() { $hundreds = array(100 => 'einhundert', 101 => 'einhunderteins', 199 => 'einhundertneunundneunzig', 203 => 'zweihundertdrei', 287 => 'zweihundertsiebenundachtzig', 300 => 'dreihundert', 356 => 'dreihundertsechsundfünfzig', 410 => 'vierhundertzehn', 434 => 'vierhundertvierunddreißig', 578 => 'fünfhundertachtundsiebzig', 689 => 'sechshundertneunundachtzig', 729 => 'siebenhundertneunundzwanzig', 894 => 'achthundertvierundneunzig', 999 => 'neunhundertneunundneunzig' ); foreach ($hundreds as $number => $word) { $this->assertEquals($word, $this->handle->toWords($number, 'de')); } } /** * Testing numbers between 1000 and 9999 */ function testThousands() { $thousands = array(1000 => 'eintausend', 1001 => 'eintausendeins', 1097 => 'eintausendsiebenundneunzig', 1104 => 'eintausendeinhundertvier', 1243 => 'eintausendzweihundertdreiundvierzig', 2385 => 'zweitausenddreihundertfünfundachtzig', 3766 => 'dreitausendsiebenhundertsechsundsechzig', 4196 => 'viertausendeinhundertsechsundneunzig', 5846 => 'fünftausendachthundertsechsundvierzig', 6459 => 'sechstausendvierhundertneunundfünfzig', 7232 => 'siebentausendzweihundertzweiunddreißig', 8569 => 'achttausendfünfhundertneunundsechzig', 9539 => 'neuntausendfünfhundertneununddreißig' ); foreach ($thousands as $number => $word) { $this->assertEquals($word, $this->handle->toWords($number, 'de')); } } } if (PHPUnit_MAIN_METHOD == 'Numbers_Words_GermanTest::main') { Numbers_Words_GermanTest::main(); } Numbers_Words-0.16.4/tests/HungarianTest.php0000644000076500007650000001421611732225114017520 0ustar igorigor * @license http://www.php.net/license/3_01.txt PHP License 3.01 * @link http://pear.php.net/package/Numbers_Words */ /* * PEAR QA suggests that we do not set * error_reporting * * error_reporting(E_ALL | E_STRICT); */ ini_set('display_errors', 1); if (!defined('PHPUnit_MAIN_METHOD')) { define('PHPUnit_MAIN_METHOD', 'Numbers_Words_HungarianTest::main'); } require_once 'Numbers/Words.php'; require_once 'PHPUnit/Framework/TestCase.php'; class Numbers_Words_HungarianTest extends PHPUnit_Framework_TestCase { var $handle; var $lang = 'hu_HU'; public static function main() { require_once 'PHPUnit/TextUI/TestRunner.php'; PHPUnit_TextUI_TestRunner::run( new PHPUnit_Framework_TestSuite('Numbers_Words_HungarianTest') ); } function setUp() { $this->handle = new Numbers_Words(); } /** * Testing numbers between 0 and 9 */ function testDigits() { $digits = array('nulla', 'egy', 'kettõ', 'három', 'négy', 'öt', 'hat', 'hét', 'nyolc', 'kilenc' ); for ($i = 0; $i < 10; $i++) { $number = $this->handle->toWords($i, $this->lang); $this->assertEquals($digits[$i], $number); } } /** * Testing numbers between 10 and 99 */ function testTens() { $tens = array(11 => 'tizenegy', 12 => 'tizenkettõ', 16 => 'tizenhat', 19 => 'tizenkilenc', 20 => 'húsz', 21 => 'húszonegy', 26 => 'húszonhat', 30 => 'harminc', 31 => 'harmincegy', 40 => 'negyven', 43 => 'negyvenhárom', 50 => 'ötven', 55 => 'ötvenöt', 60 => 'hatvan', 67 => 'hatvanhét', 70 => 'hetven', 79 => 'hetvenkilenc' ); foreach ($tens as $number => $word) { $this->assertEquals($word, $this->handle->toWords($number, $this->lang)); } } /** * Testing numbers between 100 and 999 */ function testHundreds() { $hundreds = array(100 => 'egyszáz', 101 => 'egyszázegy', 199 => 'egyszázkilencvenkilenc', 203 => 'kettõszázhárom', 287 => 'kettõszáznyolcvanhét', 300 => 'háromszáz', 356 => 'háromszázötvenhat', 410 => 'négyszáztíz', 434 => 'négyszázharmincnégy', 578 => 'ötszázhetvennyolc', 689 => 'hatszáznyolcvankilenc', 729 => 'hétszázhúszonkilenc', 894 => 'nyolcszázkilencvennégy', 999 => 'kilencszázkilencvenkilenc' ); foreach ($hundreds as $number => $word) { $this->assertEquals($word, $this->handle->toWords($number, $this->lang)); } } /** * Testing numbers between 1000 and 9999 */ function testThousands() { $thousands = array(1000 => 'egyezer', 1001 => 'egyezeregy', 1097 => 'egyezerkilencvenhét', 1104 => 'egyezeregyszáznégy', 1243 => 'egyezerkettõszáznegyvenhárom', 2385 => 'kettõezer-háromszáznyolcvanöt', 3766 => 'háromezer-hétszázhatvanhat', 4196 => 'négyezer-egyszázkilencvenhat', 5846 => 'ötezer-nyolcszáznegyvenhat', 6459 => 'hatezer-négyszázötvenkilenc', 7232 => 'hétezer-kettõszázharminckettõ', 8569 => 'nyolcezer-ötszázhatvankilenc', 9539 => 'kilencezer-ötszázharminckilenc' ); foreach ($thousands as $number => $word) { $this->assertEquals($word, $this->handle->toWords($number, $this->lang)); } } /** */ function testMore() { $this->assertEquals('egymillió', $this->handle->toWords(1000000, $this->lang)); $this->assertEquals('egymillió-egyezer-ötszáz', $this->handle->toWords(1001500, $this->lang)); $this->assertEquals('kettõmillió-egy', $this->handle->toWords(2000001, $this->lang)); $this->assertEquals('nyolcmillió-kettõezer-egy', $this->handle->toWords(8002001, $this->lang)); $this->assertEquals('kettõmilliárd', $this->handle->toWords(2000000000, $this->lang)); // 32 bit systems vs PHP_INT_SIZE - 3 billion is a little high, so use a string version. $number = '3000000000000' > PHP_INT_SIZE? '3000000000000' : 3000000000000; $this->assertEquals('hárombillió', $this->handle->toWords($number, $this->lang)); } } if (PHPUnit_MAIN_METHOD == 'Numbers_Words_HungarianTest::main') { Numbers_Words_HungarianTest::main(); } Numbers_Words-0.16.4/tests/ItalianTest.php0000644000076500007650000001002111732225114017153 0ustar igorigor * @copyright 1997-2008 The PHP Group * @license http://www.php.net/license/3_01.txt PHP License 3.01 * @version SVN: $Id$ * @link http://pear.php.net/package/Numbers_Words */ require_once 'Numbers/Words.php'; require_once 'PHPUnit/Framework/TestCase.php'; class Numbers_Words_ItalianTest extends PHPUnit_Framework_TestCase { protected $handle; public function setUp() { $this->handle = new Numbers_Words(); } /** * Testing numbers between 0 and 9 */ function testDigits() { $digits = array( 'zero', 'uno', 'due', 'tre', 'quattro', 'cinque', 'sei', 'sette', 'otto', 'nove', ); for ($i = 0; $i < 10; $i++) { $number = $this->handle->toWords($i, 'it_IT'); $this->assertEquals($digits[$i], $number); } } /** * Testing numbers between 10 and 99 */ function testTens() { $tens = array( 11 => 'undici', 12 => 'dodici', 16 => 'sedici', 19 => 'diciannove', 20 => 'venti', 21 => 'ventuno', 26 => 'ventisei', 30 => 'trenta', 31 => 'trentuno', 40 => 'quaranta', 43 => 'quarantatre', 50 => 'cinquanta', 55 => 'cinquantacinque', 60 => 'sessanta', 67 => 'sessantasette', 70 => 'settanta', 79 => 'settantanove', ); foreach ($tens as $number => $word) { $this->assertEquals($word, $this->handle->toWords($number, 'it_IT')); } } /** * Testing numbers between 100 and 999 */ function testHundreds() { $hundreds = array( 100 => 'cento', 101 => 'centouno', 199 => 'centonovantanove', 203 => 'duecentotre', 287 => 'duecentoottantasette', 300 => 'trecento', 356 => 'trecentocinquantasei', 410 => 'quattrocentodieci', 434 => 'quattrocentotrentaquattro', 578 => 'cinquecentosettantotto', 689 => 'seicentoottantanove', 729 => 'settecentoventinove', 894 => 'ottocentonovantaquattro', 999 => 'novecentonovantanove' ); foreach ($hundreds as $number => $word) { $this->assertEquals($word, $this->handle->toWords($number, 'it_IT')); } } /** * Testing numbers between 1000 and 9999 */ function testThousands() { $thousands = array( 1000 => 'mille', 1001 => 'milleuno', 1097 => 'millenovantasette', 1104 => 'millecentoquattro', 1243 => 'milleduecentoquarantatre', 2385 => 'duemilatrecentoottantacinque', 3766 => 'tremilasettecentosessantasei', 4196 => 'quattromilacentonovantasei', 5846 => 'cinquemilaottocentoquarantasei', 6459 => 'seimilaquattrocentocinquantanove', 7232 => 'settemiladuecentotrentadue', 8569 => 'ottomilacinquecentosessantanove', 9539 => 'novemilacinquecentotrentanove', ); foreach ($thousands as $number => $word) { $this->assertEquals($word, $this->handle->toWords($number, 'it_IT')); } } } Numbers_Words-0.16.4/tests/PolishTest.php0000755000076500007650000001172711732225114017051 0ustar igorigor * @copyright 1997-2008 The PHP Group * @license http://www.php.net/license/3_01.txt PHP License 3.01 * @version SVN: $Id$ * @link http://pear.php.net/package/Numbers_Words */ require_once 'Numbers/Words.php'; require_once 'PHPUnit/Framework/TestCase.php'; class Numbers_Words_PolishTest extends PHPUnit_Framework_TestCase { var $handle; function setUp() { $this->handle = new Numbers_Words(); } /** * Testing numbers between 0 and 9 */ function testDigits() { $digits = array('zero', 'jeden', 'dwa', 'trzy', 'cztery', 'piêæ', 'sze¶æ', 'siedem', 'osiem', 'dziewiêæ' ); for ($i = 0; $i < 10; $i++) { $number = $this->handle->toWords($i, 'pl'); $this->assertEquals($digits[$i], $number); } } /** * Testing numbers between 10 and 99 */ function testTens() { $tens = array(11 => 'jedena¶cie', 12 => 'dwana¶cie', 16 => 'szesna¶cie', 19 => 'dziewiêtna¶cie', 20 => 'dwadzie¶cia', 21 => 'dwadzie¶cia jeden', 26 => 'dwadzie¶cia sze¶æ', 30 => 'trzydzie¶ci', 31 => 'trzydzie¶ci jeden', 40 => 'czterdzie¶ci', 43 => 'czterdzie¶ci trzy', 50 => 'piêædziesi±t', 55 => 'piêædziesi±t piêæ', 60 => 'sze¶ædziesi±t', 67 => 'sze¶ædziesi±t siedem', 70 => 'siedemdziesi±t', 79 => 'siedemdziesi±t dziewiêæ' ); foreach ($tens as $number => $word) { $this->assertEquals($word, $this->handle->toWords($number, 'pl')); } } /** * Testing numbers between 100 and 999 */ function testHundreds() { $hundreds = array(100 => 'sto', 101 => 'sto jeden', 199 => 'sto dziewiêædziesi±t dziewiêæ', 203 => 'dwie¶cie trzy', 287 => 'dwie¶cie osiemdziesi±t siedem', 300 => 'trzysta', 356 => 'trzysta piêædziesi±t sze¶æ', 410 => 'czterysta dziesiêæ', 434 => 'czterysta trzydzie¶ci cztery', 578 => 'piêæset siedemdziesi±t osiem', 689 => 'sze¶æset osiemdziesi±t dziewiêæ', 729 => 'siedemset dwadzie¶cia dziewiêæ', 894 => 'osiemset dziewiêædziesi±t cztery', 999 => 'dziewiêæset dziewiêædziesi±t dziewiêæ' ); foreach ($hundreds as $number => $word) { $this->assertEquals($word, $this->handle->toWords($number, 'pl')); } } /** * Testing numbers between 1000 and 9999 */ function testThousands() { $thousands = array(1000 => 'jeden tysi±c', 1001 => 'jeden tysi±c jeden', 1097 => 'jeden tysi±c dziewiêædziesi±t siedem', 1104 => 'jeden tysi±c sto cztery', 1243 => 'jeden tysi±c dwie¶cie czterdzie¶ci trzy', 2385 => 'dwa tysi±ce trzysta osiemdziesi±t piêæ', 3766 => 'trzy tysi±ce siedemset sze¶ædziesi±t sze¶æ', 4196 => 'cztery tysi±ce sto dziewiêædziesi±t sze¶æ', 5846 => 'piêæ tysiêcy osiemset czterdzie¶ci sze¶æ', 6459 => 'sze¶æ tysiêcy czterysta piêædziesi±t dziewiêæ', 7232 => 'siedem tysiêcy dwie¶cie trzydzie¶ci dwa', 8569 => 'osiem tysiêcy piêæset sze¶ædziesi±t dziewiêæ', 9539 => 'dziewiêæ tysiêcy piêæset trzydzie¶ci dziewiêæ' ); foreach ($thousands as $number => $word) { $this->assertEquals($word, $this->handle->toWords($number, 'pl')); } } } Numbers_Words-0.16.4/tests/PortugueseBrazilianTest.php0000644000076500007650000002001311732225114021572 0ustar igorigor * @copyright 1997-2008 The PHP Group * @license http://www.php.net/license/3_01.txt PHP License 3.01 * @version SVN: $Id$ * @link http://pear.php.net/package/Numbers_Words */ require_once 'Numbers/Words.php'; require_once 'PHPUnit/Framework/TestCase.php'; class Numbers_Words_PortugueseBrazilianTest extends PHPUnit_Framework_TestCase { protected $handle; public function setUp() { $this->handle = new Numbers_Words(); } /** * Testing numbers between 0 and 9 */ function testDigits() { $digits = array('zero', 'um', 'dois', 'três', 'quatro', 'cinco', 'seis', 'sete', 'oito', 'nove' ); for ($i = 0; $i < 10; $i++) { $number = $this->handle->toWords($i, 'pt_BR'); $this->assertEquals($digits[$i], $number); if ($i > 0) { $number = $this->handle->toWords(-$i, 'pt_BR'); $this->assertEquals($digits[$i].' negativo', $number); } } } /** * Testing numbers between 10 and 99 */ function testTens() { $tens = array(11 => 'onze', 12 => 'doze', 16 => 'dezesseis', 19 => 'dezenove', 20 => 'vinte', 21 => 'vinte e um', 26 => 'vinte e seis', 30 => 'trinta', 31 => 'trinta e um', 40 => 'quarenta', 43 => 'quarenta e três', 50 => 'cinqüenta', 55 => 'cinqüenta e cinco', 60 => 'sessenta', 67 => 'sessenta e sete', 70 => 'setenta', 79 => 'setenta e nove' ); foreach ($tens as $number => $word) { $this->assertEquals($word, $this->handle->toWords($number, 'pt_BR')); $this->assertEquals("$word negativo", $this->handle->toWords(-$number, 'pt_BR')); } } /** * Testing numbers between 100 and 999 */ function testHundreds() { $hundreds = array(100 => 'cem', 101 => 'cento e um', 199 => 'cento e noventa e nove', 203 => 'duzentos e três', 287 => 'duzentos e oitenta e sete', 300 => 'trezentos', 356 => 'trezentos e cinqüenta e seis', 410 => 'quatrocentos e dez', 434 => 'quatrocentos e trinta e quatro', 578 => 'quinhentos e setenta e oito', 689 => 'seiscentos e oitenta e nove', 729 => 'setecentos e vinte e nove', 717 => 'setecentos e dezessete', 894 => 'oitocentos e noventa e quatro', 999 => 'novecentos e noventa e nove' ); foreach ($hundreds as $number => $word) { $this->assertEquals($word, $this->handle->toWords($number, 'pt_BR')); $this->assertEquals("$word negativo", $this->handle->toWords(-$number, 'pt_BR')); } } /** * Testing numbers between 1000 and 9999 */ function testThousands() { $thousands = array(1000 => 'um mil', 1001 => 'um mil e um', 1097 => 'um mil e noventa e sete', 1104 => 'um mil cento e quatro', 1243 => 'um mil duzentos e quarenta e três', 2200 => 'dois mil e duzentos', 2385 => 'dois mil trezentos e oitenta e cinco', 3766 => 'três mil setecentos e sessenta e seis', 4196 => 'quatro mil cento e noventa e seis', 5846 => 'cinco mil oitocentos e quarenta e seis', 6459 => 'seis mil quatrocentos e cinqüenta e nove', 7232 => 'sete mil duzentos e trinta e dois', 8569 => 'oito mil quinhentos e sessenta e nove', 9539 => 'nove mil quinhentos e trinta e nove' ); foreach ($thousands as $number => $word) { $this->assertEquals($word, $this->handle->toWords($number, 'pt_BR')); $this->assertEquals("$word negativo", $this->handle->toWords(-$number, 'pt_BR')); } } /** * Testing numbers greater than 9999 */ function testMillions() { $millions = array(1000001 => 'um milhão e um', 2000025 => 'dois milhões e vinte e cinco', 5100000 => 'cinco milhões e cem mil', 5015004 => 'cinco milhões quinze mil e quatro', 5123000 => 'cinco milhões cento e vinte e três mil', 7100100 => 'sete milhões cem mil e cem', 8100345 => 'oito milhões cem mil trezentos e quarenta e cinco', 8000016 => 'oito milhões e dezesseis', 100000001 => 'cem milhões e um', 345199054 => 'trezentos e quarenta e cinco milhões cento e noventa e nove mil e cinqüenta e quatro', 1000077000 => 'um bilhão e setenta e sete mil', 1000777000 => 'um bilhão setecentos e setenta e sete mil', ); foreach ($millions as $number => $word) { $this->assertEquals($word, $this->handle->toWords($number, 'pt_BR')); $this->assertEquals("$word negativo", $this->handle->toWords(-$number, 'pt_BR')); } } /** * Testing Currency */ function testCurrency() { $money = array('1.00' => 'um real', '1.01' => 'um real e um centavo', '1.10' => 'um real e dez centavos', '1.11' => 'um real e onze centavos', '1.21' => 'um real e vinte e um centavos', '2.00' => 'dois reais', '2.01' => 'dois reais e um centavo', '2.10' => 'dois reais e dez centavos', '2.11' => 'dois reais e onze centavos', '2.21' => 'dois reais e vinte e um centavos', '0.01' => 'um centavo de real', '0.45' => 'quarenta e cinco centavos de real', '1000.00' => 'um mil reais', '1000000.00' => 'um milhão de reais', '1000001.00' => 'um milhão e um reais', '1100000.00' => 'um milhão e cem mil reais', '100001000000' => 'cem bilhões e um milhão de reais', '1000000000' => 'um bilhão de reais', ); foreach ($money as $number => $word) { $this->assertEquals($word, $this->handle->toCurrency($number, 'pt_BR')); $this->assertEquals("$word negativo", $this->handle->toCurrency(-$number, 'pt_BR')); } } } Numbers_Words-0.16.4/tests/SpanishTest.php0000755000076500007650000001230411732225114017210 0ustar igorigorhandle = new Numbers_Words(); } /** * Testing numbers between 0 and 9 */ function testDigits() { $digits = array('cero', 'uno', 'dos', 'tres', 'cuatro', 'cinco', 'seis', 'siete', 'ocho', 'nueve' ); for ($i = 0; $i < 10; $i++) { $number = $this->handle->toWords($i, 'es'); $this->assertEquals($digits[$i], $number); } } /** * Testing numbers between 10 and 99 */ function testTens() { $tens = array(11 => 'once', 12 => 'doce', 16 => 'dieciseis', 19 => 'diecinueve', 20 => 'veinte', 21 => 'veintiuno', 26 => 'veintiseis', 30 => 'treinta', 31 => 'treinta y uno', 40 => 'cuarenta', 43 => 'cuarenta y tres', 50 => 'cincuenta', 55 => 'cincuenta y cinco', 60 => 'sesenta', 67 => 'sesenta y siete', 70 => 'setenta', 79 => 'setenta y nueve' ); foreach ($tens as $number => $word) { $this->assertEquals($word, $this->handle->toWords($number, 'es')); } } /** * Testing numbers between 100 and 999 */ function testHundreds() { $hundreds = array(100 => 'cien', 101 => 'ciento uno', 199 => 'ciento noventa y nueve', 203 => 'doscientos tres', 287 => 'doscientos ochenta y siete', 300 => 'trescientos', 356 => 'trescientos cincuenta y seis', 410 => 'cuatrocientos diez', 434 => 'cuatrocientos treinta y cuatro', 578 => 'quinientos setenta y ocho', 689 => 'seiscientos ochenta y nueve', 729 => 'setecientos veintinueve', 894 => 'ochocientos noventa y cuatro', 999 => 'novecientos noventa y nueve' ); foreach ($hundreds as $number => $word) { $this->assertEquals($word, $this->handle->toWords($number, 'es')); } } /** * Testing numbers between 1000 and 9999 */ function testThousands() { $thousands = array(1000 => 'mil', 1001 => 'mil uno', 1097 => 'mil noventa y siete', 1104 => 'mil ciento cuatro', 1243 => 'mil doscientos cuarenta y tres', 2385 => 'dos mil trescientos ochenta y cinco', 3766 => 'tres mil setecientos sesenta y seis', 4196 => 'cuatro mil ciento noventa y seis', 5846 => 'cinco mil ochocientos cuarenta y seis', 6459 => 'seis mil cuatrocientos cincuenta y nueve', 7232 => 'siete mil doscientos treinta y dos', 8569 => 'ocho mil quinientos sesenta y nueve', 9539 => 'nueve mil quinientos treinta y nueve' ); foreach ($thousands as $number => $word) { $this->assertEquals($word, $this->handle->toWords($number, 'es')); } } } Numbers_Words-0.16.4/tests/test-numbers-words.php0000644000076500007650000000721711732225114020533 0ustar igorigorTest number: $shownum

\n"; else echo sprintf("%42s", 'Test number: ') . $shownum . "\n\n"; $lang = Numbers_Words::getLocales(); $langs = array(); if ($html_on) { ?>

toWords($num); if (PEAR::isError($ret)) { if ($html_on) { } echo "Error ($loc_symbol): " . $ret->message . "\n"; if ($html_on) { } } else { $loc_name = $obj->lang; $langs[$loc_symbol] = $loc_name; if ($html_on) { ?> toCurrency($num, $loc_symbol); if (PEAR::isError($ret)) { if ($html_on) { } echo "Error ($loc_symbol): " . $ret->message . "\n"; if ($html_on) { } } else { if ($html_on) { ?>
Symbol Number system String
Numbers_Words-0.16.4/ChangeLog0000644000076500007650000001724511732225114014650 0ustar igorigor2012-02-22 * Numbers_Words: Version 0.16.4 released. * Re-licensed to PHP 3.01 (ifeghali) 2011-12-10 * Bug #12512 Windows incorrect declaration of toWords() (ifeghali) * Bug #17373 bug in toWords function for hungarian translation (kouber) * Bug #17392 bugs in toWords function for hungarian translation (ifeghali) * Bug #17754 Patch: Using explode instead of split (ifeghali) * Request #17763 Independent tr_TR Lang support (ifeghali) * Bug #17794 Patch: avoiding split in es_MX file (ifeghali) * Bug #18501 incorrect declaration of toWords() in lang.fr.php (kouber) * Bug #19013 remove error_reporting (for PEAR QA team) (ifeghali) 2010-05-10 * Numbers_Words: Version 0.16.2 released. * Words.php: incorrect rounding of cents (Bug #16733). * Words/lang.pl.php: improper use of substr() in Polish extension (Bug #16435). * Words/lang.hu_HU.php: wrong spelling of 40 in Hungarian extension (Bug #16667) (Vlajos). * tests/AllTests.php: switch to TextUI/TestRunner.php framework (Daniel O'Connor). 2009-03-14 * Numbers_Words: Version 0.16.1 released. * Words.php: better cast/sanitize to int. * Words/lang.it_IT.php: fixed incorrect trimming of vowels (Bug #16019) (Filippo Beltramini). * tests/ItalianTest.php: incorrect trimming, reveling Bug #16019 (Lorenzo Alberton). * tests/*: fix line endings. 2008-03-10 * Numbers_Words: Version 0.16.0 released. * Words.php: fixed wrong getLocales() Docblock bug (#10744) (Daniel O'Connor). * Words.php: fixed bogus non-int parsing (#14988) (Daniel O'Connor). * Words/lang.cs.php: fixed bad trascription for 101 numbers and 102 thousands bug (#14667) (Daniel O'Connor). * Words/lang.fr_BE.php: fixed a bug involving incorrect values for 80 and 81 (Kouber Saparev). * Words/lang.pt_BR.php: bug fix (#15260) (Igor Feghali). * tests/*: Swap to PHPUnit 3 (Daniel O'Connor). * Numerous language unit tests added (bg, en_100, en_gb, en_us, fr, fr_BE, de, it, pt_BR). * Fix numerous coding standard issues (bug #15145). 2006-06-12 * Numbers_Words: Version 0.15.0 released. * Words/lang.nl.php: New language file: nl for Dutch (Thanks to WHAM van Dinter) * Words/lang.et.php: changed locale name for Estonian language from 'ee' to 'et' (#5618). * Words/lang.ru.php: fixed bug in Russian translation (if x modulo 10 was equal to 0) (#6654). * Words.php: new Numbers_Words::getLocales() method (Thanks to Bertrand Gugger). * tests/test-numbers-words.php: updated to use getLocales(). * package.xml: updated to version 2.0. 2005-09-19 * Numbers_Words: Version 0.14.0 released. * Words/lang.*.php: added $convert_fraction optional argument that allow to not convert fraction part in toCurrencyWorkds() method. * Words/lang.en_GB.php: fixed plural of pence; toCurrency() method added. 2005-03-09 * Numbers_Words: Version 0.13.1 released. * Words.php: Fixed a problem with no leading zero in fraction of the currency value (reported by geekdom at gmail dot com). 2005-02-28 * Numbers_Words: Version 0.13.0 released. * support for a new currency ILS (or NIS) for New Israeli Sheqel 2005-02-15 * Words/lang.cs.php: New language file: cs for Czech (Thanks to Petr 'PePa' Pavel) 2005-02-03 * Words/lang.he.php: New language file: he for Hebrew (Thanks to Hadar Porat) 2005-01-11 * Numbers_Words: Version 0.12.0 released. * Words/lang.fr_BE.php: New language file: fr_BE for French (Belgium) (Thanks to Philippe Bajoit). 2004-10-25 * Fixed spell mistake in some files - Britich to British (Thanks to Christian Weiske) 2004-10-22 * Numbers_Words: Version 0.11.0 released. * Words/lang.pt_BR.php: toCurrencyWords() support in pt_BR translation (Thanks to Mario H.C.T). 2004-09-30 * Numbers_Words: Version 0.10.1 released. * Words/lang.de.php: Small bug fix to German translation (the one thousand) (Thanks to neuner at futureweb dot at for the fix). * tests/test-numbers-words.php: Changed test number. 2004-09-20 * Numbers_Words: Version 0.10.0 released. * Words/lang.dk.php: New language file: dk for Danish (Author: Jesper Veggerby) 2004-08-26 * Numbers_Words: Version 0.9.0 released. * Words/lang.hu_HU.php: New language file: hu_HU for Hungarian (Author: Nils Homp) * Words/lang.id.php: Updating author list of the Indonesian translation (Arif Rifai Dwiyanto translated into Indonesian first but I missed his file by mistake). 2004-08-09 * Numbers_Words: Version 0.8.1 released. * Words/lang.ru.php: fixed two bugs (missing t in 400, and wrong function call) in Russian translation (thanks to Anton Funk and igorag for reporting, and Andrey Demenev for fixing) 2004-06-17 * Numbers_Words: Version 0.8 released. * Words/lang.lt.php: New file for Lithuanian language. * Words.php: Fixed a class method finding (should work for PHP5 and PHP4 now) 2004-05-25 * Numbers_Words: Version 0.7.1 released. * Words.php: Small fix for PHP 5 support (toWords instead of towords) (Thanks to khlo for bug report). 2004-04-28 * Numbers_Words: Version 0.7 released. * Words/lang.fr.php, Words/lang.bg.php: small fix of minus sign (Kouber Saparev) * Words/lang.sv.pl: New language file: sv for Swedish (Author: Robin Ericsson) 2004-04-27 * Numbers_Words: Version 0.6 released. 2004-04-17 * Words/lang.ru.php: New language file: ru for Russian (Author: Andrey Demenev) 2004-03-25 * Words/lang.id.php: New language file: id for Indonesian (Author: Ernas M. Jamil) 2004-03-02 * Words/lang.es_AR.php: New language file: es_AR for Argentinian Spanish (Author: Martin Marrese) 2003-12-16 * Numbers_Words: Version 0.5.1 release. * Words/lang.fr.php: Small fix to French translation. 2003-12-16 * Numbers_Words: Version 0.5 release. * Words/lang.en_US.php: toCurrency() method for spelling given amount of money. 2003-12-11 * Words/lang.fr.php: New language file: fr for French (Author: Kouber Saparev) 2003-11-21 * Words/lang.bg.php: New language file: bg for Bulgarian (Author: Kouber Saparev) 2003-09-29 * Numbers_Words: Version 0.4 release. * Words.php: eliminate PEAR.php run-time loading * all files: comments small changes to be more usable for phpdoc 2003-09-17 * Words/lang.it_IT.php: New language file: it_IT for Italian (Authors: Filippo Beltramini, Davide Caironi) * Words.php, Words/lang.pl.php: toCurrency() method for spelling given amount of money. 2003-09-15 * Words/lang.ee.php: New language file: ee for Estonian (Author: Erkki Saarniit) * Words/lang.es.php: extranous spaces deleted. * Words.php: trim output, new function for converting currency. * tests: new test suite (PHPUnits). 2002-11-27 * Numbers_Words: Version 0.3.1 release. * Words/lang.pt_BR.php: fixing spell mistake for native language name 2002-11-26 * Numbers_Words: Version 0.3 release (first PEAR release). * Words/lang.es.php: New language file: es for Spanish (Author: Xavier Noguer) * Words/lang.de.php: New language file: de for German (Author: Piotr Klaban) * Words/lang.pt_BR.php: New language file: pt_BR for Brazilian Portuguese (Author: Marcelo Subtil Marcal ) * all files: PHP License upgrade to 3.0 * test-numbers-words.php: HTML and text mode enabled * Words/lang.*.php: New $lang_native, $locale variables. * test-numbers-words.php: New language file, en_100 uses Donald Knuth number spelling system. 2002-11-19 * package.xml: New version 0.2 released. * Words/lang.en_100.php: New language file, en_100 uses Donald Knuth number spelling system. * Words/lang.pt_BR.php: New language file, pt_BR for Brazilian Portuguese (Thanks to Marcelo Subtil Marcal). 2002-11-18 14:00 * Words/lang.*.php: Bad conversion of zero number fixed (Thanks to Xavier Noguer). 2002-11-18 10:00 * all files: Changing name from Numbers_Spell to Numbers_Words 2002-11-15 15:04 makler * package.xml, Spell.php: Changing file location 2002-11-15 14:47 makler * package.xml: CVS initialization. Numbers_Words-0.16.4/LICENSE0000644000076500007650000000622211732225114014074 0ustar igorigor-------------------------------------------------------------------- The PHP License, version 3.01 Copyright (c) 1999 - 2010 The PHP Group. All rights reserved. -------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without modification, is permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name "PHP" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact group@php.net. 4. Products derived from this software may not be called "PHP", nor may "PHP" appear in their name, without prior written permission from group@php.net. You may indicate that your software works in conjunction with PHP by saying "Foo for PHP" instead of calling it "PHP Foo" or "phpfoo" 5. The PHP Group may publish revised and/or new versions of the license from time to time. Each version will be given a distinguishing version number. Once covered code has been published under a particular version of the license, you may always continue to use it under the terms of that version. You may also choose to use such covered code under the terms of any subsequent version of the license published by the PHP Group. No one other than the PHP Group has the right to modify the terms applicable to covered code created under this License. 6. Redistributions of any form whatsoever must retain the following acknowledgment: "This product includes PHP software, freely available from ". THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PHP DEVELOPMENT TEAM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------- This software consists of voluntary contributions made by many individuals on behalf of the PHP Group. The PHP Group can be contacted via Email at group@php.net. For more information on the PHP Group and the PHP project, please see . PHP includes the Zend Engine, freely available at . Numbers_Words-0.16.4/README0000644000076500007650000001304611732225114013751 0ustar igorigor** Introduction: With PEAR::Numbers_Words class you can change an integer number to simple words. This can be usefull when you need to spell a currency value e.g. on an invoice. You can choose between several languages (language files are located in Numbers/Words/ directory). BTW: if you need to change number to currency, use money_format() PHP function (available since 4.3 (not yet released)). But you must know that locale LC_MONETARY rules are sometimes unclear. ** Getting started: First you need to install Numbers_Words PEAR package. You can do it (as root) with: pear install Numbers_Words In your php script you need to load Numbers/Words.php header file: require_once('Numbers/Words.php'); Then you can call Numbers_Words::toWords() function with two arguments: integer number (can be a string with digits) and optional locale name (default is en_US): $ret = Numbers_Words::toWords($num,"en_GB"); if (PEAR::isError($ret)) { echo "Error: " . $ret->message . "\n"; } else { echo "Num $num in British English is '$ret'

\n"; } For this would display: Num 12340000000 in British English is 'twelve thousand million three hundred forty million'

** Current State: The current release can be found at the PEAR webpage: http://pear.php.net/package-info.php?package=Numbers_Words For the time of writting this Readme file, Numbers_spell package has the status beta, which means there can be samo bugs, and it is under development. This is not mature code. ** Development This package needs help from people, who can write language modules other than Polish and English. ** Package Content: Readme.txt - this file ChangeLog - change log test-numbers-words.php - test file showing Numbers_Words example usage Words.php - main class file, that loads language modules on demand Words/lang.{LOCALE_NAME}.php - language modules There are avaibale the following modules (called by locale name, in alphabetical order): bg - Bulgarian language (in WIN-1251 charset). Author: Kouber Saparev cs - Czech language. Author: Petr 'PePa' Pavel de - German language. Author: Piotr Klaban dk - Danish language. Author: Jesper Veggerby en_100 - Donald Knuth number naming system, in English language. Author: Piotr Klaban en_GB - British English notation of numbers, where one billion is 1000000 times one million. 1000 times million is just 'thousand million' here. I do not use a word billiard here, because English people do not use it often, and even could not know it. Author: Piotr Klaban en_US - American English notation of numbers, where one billion is 1000 times one million Author: Piotr Klaban es - Spanish (Castellano) language. Author: Xavier Noguer es_AR - Argentinian Spanish language. Author: Martin Marrese et - Estonian language. Author: Erkki Saarniit fr - French language. Author: Kouber Saparev fr_BE - French (Belgium) language. Author: Kouber Saparev, Philippe Bajoit he - Hebrew language. Author: Hadar Porat hu_HU - Hungarian language. Author: Nils Homp id - Indonesia language. Authors: Ernas M. Jamil, Arif Rifai Dwiyanto it_IT - Italian language. Authors: Filippo Beltramini, Davide Caironi lt - Lithuanian language. Author: Laurynas Butkus nl - Dutch language. Author: WHAM van Dinter pl - Polish language (in an internet standard charset ISO-8859-2) Author: Piotr Klaban pt_BR - Brazilian Portuguese language. Authors: Marcelo Subtil Marcal, Mario H.C.T., Igor Feghali ru - Russian language. Author: Andrey Demenev sv - Swedich language. Author: Robin Ericsson tr_TR - Turkish language. Author: Shahriyar Imanov ** What if numbers have fraction part? You can split the number by the coma or dot. The example function was provided by Ernas M. Jamil (see below). I do not know if the splitting and concatenating numbers should be supported by Numbers_Words ... Does each language spell numbers with a 'coma'/'koma'? What do you think? function num2word($num, $fract = 0) { require_once('Numbers/Words.php'); $num = sprintf("%.".$fract."f", $num); $fnum = explode('.', $num); $ret = Numbers_Words::toWords($fnum[0],"id"); if(!$fract) return $ret; $ret .= ' koma '; // point in english $ret .= Numbers_Words::toWords($fnum[1],"id"); return $ret; } ** How to convert decimal part and not fraction part of the currency value? Rob King send me a patch that would allow to leave fraction part in digits. I.e. you can convert 31.01 into 'thirty-one pounds 01 pence': require_once('Numbers/Words.php'); require_once('Numbers/Words/lang.en_GB.php'); $obj = new Numbers_Words_en_GB; $convert_fraction = false; print $obj->toCurrencyWords('GBP', '31', '01', $convert_fraction) . "\n"; ** How to write new Language Files: Just copy existing en_US or en_GB etc. file into lang.{your_country/locale code}.php and translate digits, numbers, tousands to your language. Then please send it to the author to the address makler@man.torun.pl. ** Credits All changes from other people are desrcribed with details in ChangeLog. There are also names of the people who send me patches etc. Authors of the language files are mentioned in the language files directly as the author.