cvs: pear /Numbers_Words ChangeLog README package.xml /Numbers_Words/Words lang.dk.php lang.en_GB.php lang.en_US.php lang.es_AR.php lang.he.php
lang.hu_HU.php lang.pl.php lang.pt_BR.php lang.ru.php

From: Date: Sun, 18 Sep 2005 19:52:22 +0000
Subject: cvs: pear /Numbers_Words ChangeLog README package.xml /Numbers_Words/Words lang.dk.php lang.en_GB.php lang.en_US.php lang.es_AR.php lang.he.php
lang.hu_HU.php lang.pl.php lang.pt_BR.php lang.ru.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-34854@lists.php.net to get a copy of this message
makler Sun Sep 18 15:52:22 2005 EDT Modified files: /pear/Numbers_Words ChangeLog README package.xml /pear/Numbers_Words/Words lang.dk.php lang.en_GB.php lang.en_US.php lang.es_AR.php lang.he.php lang.hu_HU.php lang.pl.php lang.pt_BR.php lang.ru.php Log: New relase version 0.14.0. Optional converting of fraction part of the currency value.

http://cvs.php.net/diff.php/pear/Numbers_Words/ChangeLog?r1=1.9&r2=1.10&ty=u Index: pear/Numbers_Words/ChangeLog diff -u pear/Numbers_Words/ChangeLog:1.9 pear/Numbers_Words/ChangeLog:1.10 --- pear/Numbers_Words/ChangeLog:1.9 Sun Sep 18 14:52:36 2005 +++ pear/Numbers_Words/ChangeLog Sun Sep 18 15:52:21 2005 @@ -1,19 +1,21 @@ 2005-09-19 - * Words/lang.en_GB.php: fixed plural of pence; toCurrency() method added. + * 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). + * 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. + * 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) + * 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) + * Words/lang.he.php: New language file: he for Hebrew (Thanks to Hadar Porat) 2005-01-11 * Numbers_Words: Version 0.12.0 released. @@ -57,7 +59,7 @@ 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.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 @@ -99,7 +101,7 @@ 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. + * Words.php: trim output, new function for converting currency. * tests: new test suite (PHPUnits). 2002-11-27 * Numbers_Words: Version 0.3.1 release. @@ -128,7 +130,7 @@ 2002-11-18 10:00 - * all files: Changing name from Numbers_Spell to Numbers_Words + * all files: Changing name from Numbers_Spell to Numbers_Words 2002-11-15 15:04 makler http://cvs.php.net/diff.php/pear/Numbers_Words/README?r1=1.7&r2=1.8&ty=u Index: pear/Numbers_Words/README diff -u pear/Numbers_Words/README:1.7 pear/Numbers_Words/README:1.8 --- pear/Numbers_Words/README:1.7 Mon Feb 28 08:22:50 2005 +++ pear/Numbers_Words/README Sun Sep 18 15:52:21 2005 @@ -79,7 +79,7 @@ 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. @@ -93,10 +93,10 @@ es - Spanish (Castellano) language. Author: Xavier Noguer - + es_AR - Argentinian Spanish language. Author: Martin Marrese - + fr - French language. Author: Kouber Saparev @@ -138,20 +138,32 @@ 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; -} +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: http://cvs.php.net/diff.php/pear/Numbers_Words/package.xml?r1=1.10&r2=1.11&ty=u Index: pear/Numbers_Words/package.xml diff -u pear/Numbers_Words/package.xml:1.10 pear/Numbers_Words/package.xml:1.11 --- pear/Numbers_Words/package.xml:1.10 Wed Mar 9 02:29:19 2005 +++ pear/Numbers_Words/package.xml Sun Sep 18 15:52:21 2005 @@ -41,13 +41,19 @@ <email>makler@man.torun.pl</email> <role>lead</role> </maintainer> + <maintainer> + <user>msmarcal</user> + <name>Marcelo Subtil Marcal</name> + <email>msmarcal@php.net</email> + <role>developer</role> + </maintainer> </maintainers> <release> - <version>0.13.1</version> - <date>2005-03-09</date> + <version>0.14.0</version> + <date>2005-09-05</date> <license>PHP License</license> <state>beta</state> - <notes>Fixed a problem with no leading zero in fraction of the currency value (reported by geekdom at gmail dot com).</notes> + <notes>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).</notes> <filelist> <file role="php" baseinstalldir="Numbers" name="Words.php"/> <file role="php" baseinstalldir="Numbers" name="Words/lang.bg.php"/> @@ -81,6 +87,13 @@ </release> <changelog> <release> + <version>0.13.1</version> + <date>2005-03-09</date> + <license>PHP License</license> + <state>beta</state> + <notes>Fixed a problem with no leading zero in fraction of the currency value (reported by geekdom at gmail dot com).</notes> + </release> + <release> <version>0.13.0</version> <date>2005-02-28</date> <license>PHP License</license> http://cvs.php.net/diff.php/pear/Numbers_Words/Words/lang.dk.php?r1=1.1&r2=1.2&ty=u Index: pear/Numbers_Words/Words/lang.dk.php diff -u pear/Numbers_Words/Words/lang.dk.php:1.1 pear/Numbers_Words/Words/lang.dk.php:1.2 --- pear/Numbers_Words/Words/lang.dk.php:1.1 Tue Sep 21 02:42:11 2004 +++ pear/Numbers_Words/Words/lang.dk.php Sun Sep 18 15:52:22 2005 @@ -17,7 +17,7 @@ // | Authors: Jesper Veggerby <pear.nosey@veggerby.dk> | // +----------------------------------------------------------------------+ // -// $Id: lang.dk.php,v 1.1 2004/09/21 06:42:11 makler Exp $ +// $Id: lang.dk.php,v 1.2 2005/09/18 19:52:22 makler Exp $ // // Numbers_Words class extension to spell numbers in Danish language. // @@ -228,22 +228,22 @@ } if ($h) { - if ($h == 1) { - $ret .= $this->_sep . 'et' . $this->_sep . 'hundrede'; - } else { - $ret .= $this->_sep . $this->_digits[$h] . $this->_sep . 'hundrede'; - } + 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'; + //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'; + // 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) { + 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" : ""); } @@ -347,7 +347,7 @@ return $ret; } // }}} - // {{{ toCurrency() + // {{{ toCurrencyWords() /** * Converts a currency value to its word representation @@ -358,6 +358,8 @@ * @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 * @@ -365,7 +367,7 @@ * @author Jesper Veggerby <pear.nosey@veggerby.dk> * @since Numbers_Words 0.4 */ - function toCurrencyWords($int_curr, $decimal, $fraction = false) { + 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; @@ -373,25 +375,29 @@ $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"; - } - } + $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)) { - $ret .= $this->_sep . trim($this->toWords($fraction)); + 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) { http://cvs.php.net/diff.php/pear/Numbers_Words/Words/lang.en_GB.php?r1=1.3&r2=1.4&ty=u Index: pear/Numbers_Words/Words/lang.en_GB.php diff -u pear/Numbers_Words/Words/lang.en_GB.php:1.3 pear/Numbers_Words/Words/lang.en_GB.php:1.4 --- pear/Numbers_Words/Words/lang.en_GB.php:1.3 Sun Sep 18 14:52:37 2005 +++ pear/Numbers_Words/Words/lang.en_GB.php Sun Sep 18 15:52:22 2005 @@ -17,7 +17,7 @@ // | Authors: Piotr Klaban <makler@man.torun.pl> | // +----------------------------------------------------------------------+ // -// $Id: lang.en_GB.php,v 1.3 2005/09/18 18:52:37 makler Exp $ +// $Id: lang.en_GB.php,v 1.4 2005/09/18 19:52:22 makler Exp $ // // Numbers_Words class extension to spell numbers in British English language. // @@ -359,7 +359,7 @@ return $ret; } // }}} - // {{{ toCurrency() + // {{{ toCurrencyWords() /** * Converts a currency value to its word representation @@ -370,6 +370,8 @@ * @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 * @@ -377,7 +379,7 @@ * @author Piotr Klaban <makler@man.torun.pl> * @since Numbers_Words 0.13.1 */ - function toCurrencyWords($int_curr, $decimal, $fraction = false) { + 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; @@ -396,7 +398,11 @@ } if ($fraction !== false) { - $ret .= $this->_sep . trim($this->toWords($fraction)); + 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) { http://cvs.php.net/diff.php/pear/Numbers_Words/Words/lang.en_US.php?r1=1.4&r2=1.5&ty=u Index: pear/Numbers_Words/Words/lang.en_US.php diff -u pear/Numbers_Words/Words/lang.en_US.php:1.4 pear/Numbers_Words/Words/lang.en_US.php:1.5 --- pear/Numbers_Words/Words/lang.en_US.php:1.4 Sun Sep 18 14:52:37 2005 +++ pear/Numbers_Words/Words/lang.en_US.php Sun Sep 18 15:52:22 2005 @@ -17,7 +17,7 @@ // | Authors: Piotr Klaban <makler@man.torun.pl> | // +----------------------------------------------------------------------+ // -// $Id: lang.en_US.php,v 1.4 2005/09/18 18:52:37 makler Exp $ +// $Id: lang.en_US.php,v 1.5 2005/09/18 19:52:22 makler Exp $ // // Numbers_Words class extension to spell numbers in American English language. // @@ -451,7 +451,7 @@ return $ret; } // }}} - // {{{ toCurrency() + // {{{ toCurrencyWords() /** * Converts a currency value to its word representation @@ -462,6 +462,8 @@ * @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 * @@ -469,7 +471,7 @@ * @author Piotr Klaban <makler@man.torun.pl> * @since Numbers_Words 0.4 */ - function toCurrencyWords($int_curr, $decimal, $fraction = false) { + 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; @@ -488,7 +490,11 @@ } if ($fraction !== false) { - $ret .= $this->_sep . trim($this->toWords($fraction)); + 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) { http://cvs.php.net/diff.php/pear/Numbers_Words/Words/lang.es_AR.php?r1=1.2&r2=1.3&ty=u Index: pear/Numbers_Words/Words/lang.es_AR.php diff -u pear/Numbers_Words/Words/lang.es_AR.php:1.2 pear/Numbers_Words/Words/lang.es_AR.php:1.3 --- pear/Numbers_Words/Words/lang.es_AR.php:1.2 Mon Feb 28 08:22:51 2005 +++ pear/Numbers_Words/Words/lang.es_AR.php Sun Sep 18 15:52:22 2005 @@ -17,7 +17,7 @@ // | Authors: Martin Marrese <mmare@mecon.gov.ar> | // | Based On: lang_es.php - Xavier Noguer | // +----------------------------------------------------------------------+ -// $Id: lang.es_AR.php,v 1.2 2005/02/28 13:22:51 makler Exp $ +// $Id: lang.es_AR.php,v 1.3 2005/09/18 19:52:22 makler Exp $ // // Numbers_Words class extension to spell numbers in Argentinian Spanish // @@ -410,7 +410,7 @@ } // }}} - // {{{ toCurrency() + // {{{ toCurrencyWords() /** * Converts a currency value to its word representation @@ -421,13 +421,15 @@ * @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) { + 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; @@ -446,7 +448,11 @@ $ret .= $this->_sep . trim($this->toWords($decimal)); if ($fraction !== false) { - $ret .= $this->_sep .'con'. $this->_sep . trim($this->toWords($fraction)); + 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) { http://cvs.php.net/diff.php/pear/Numbers_Words/Words/lang.he.php?r1=1.3&r2=1.4&ty=u Index: pear/Numbers_Words/Words/lang.he.php diff -u pear/Numbers_Words/Words/lang.he.php:1.3 pear/Numbers_Words/Words/lang.he.php:1.4 --- pear/Numbers_Words/Words/lang.he.php:1.3 Sun Sep 18 14:52:37 2005 +++ pear/Numbers_Words/Words/lang.he.php Sun Sep 18 15:52:22 2005 @@ -17,7 +17,7 @@ // | Authors: Hadar Porat | // +----------------------------------------------------------------------+ // -// $Id: lang.he.php,v 1.3 2005/09/18 18:52:37 makler Exp $ +// $Id: lang.he.php,v 1.4 2005/09/18 19:52:22 makler Exp $ // // Numbers_Words class extension to spell numbers in Hebrew language. // @@ -441,7 +441,7 @@ return $ret; } // }}} - // {{{ toCurrency() + // {{{ toCurrencyWords() /** * Converts a currency value to its word representation @@ -452,6 +452,8 @@ * @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 * @@ -459,7 +461,7 @@ * @author Piotr Klaban <makler@man.torun.pl> * @since Numbers_Words 0.4 */ - function toCurrencyWords($int_curr, $decimal, $fraction = false) { + 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; @@ -479,7 +481,11 @@ } if ($fraction !== false) { - $ret .= $this->_sep . trim($this->toWords($fraction)); + 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) { http://cvs.php.net/diff.php/pear/Numbers_Words/Words/lang.hu_HU.php?r1=1.4&r2=1.5&ty=u Index: pear/Numbers_Words/Words/lang.hu_HU.php diff -u pear/Numbers_Words/Words/lang.hu_HU.php:1.4 pear/Numbers_Words/Words/lang.hu_HU.php:1.5 --- pear/Numbers_Words/Words/lang.hu_HU.php:1.4 Sun Sep 18 14:52:37 2005 +++ pear/Numbers_Words/Words/lang.hu_HU.php Sun Sep 18 15:52:22 2005 @@ -17,7 +17,7 @@ // | Nils Homp (Hungarian version) | // +----------------------------------------------------------------------+ // -// $Id: lang.hu_HU.php,v 1.4 2005/09/18 18:52:37 makler Exp $ +// $Id: lang.hu_HU.php,v 1.5 2005/09/18 19:52:22 makler Exp $ // // Numbers_Words class extension to spell numbers in Hungarian language. // NOTE: toCurrency() was not localized and is from the en_US class. @@ -338,7 +338,7 @@ return $ret; } // }}} - // {{{ toCurrency() + // {{{ toCurrencyWords() /** * Converts a currency value to its word representation @@ -349,6 +349,8 @@ * @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 * @@ -356,7 +358,7 @@ * @author Piotr Klaban <makler@man.torun.pl> * @since Numbers_Words 0.4 */ - function toCurrencyWords($int_curr, $decimal, $fraction = false) { + 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; @@ -375,7 +377,11 @@ } if ($fraction !== false) { - $ret .= $this->_sep . trim($this->toWords($fraction)); + 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) { http://cvs.php.net/diff.php/pear/Numbers_Words/Words/lang.pl.php?r1=1.3&r2=1.4&ty=u Index: pear/Numbers_Words/Words/lang.pl.php diff -u pear/Numbers_Words/Words/lang.pl.php:1.3 pear/Numbers_Words/Words/lang.pl.php:1.4 --- pear/Numbers_Words/Words/lang.pl.php:1.3 Mon Feb 28 08:22:51 2005 +++ pear/Numbers_Words/Words/lang.pl.php Sun Sep 18 15:52:22 2005 @@ -17,7 +17,7 @@ // | Authors: Piotr Klaban <makler@man.torun.pl> | // +----------------------------------------------------------------------+ // -// $Id: lang.pl.php,v 1.3 2005/02/28 13:22:51 makler Exp $ +// $Id: lang.pl.php,v 1.4 2005/09/18 19:52:22 makler Exp $ // // Numbers_Words class extension to spell numbers in Polish. // @@ -418,7 +418,7 @@ return $ret; } // }}} - // {{{ toCurrency() + // {{{ toCurrencyWords() /** * Converts a currency value to its word representation @@ -429,6 +429,8 @@ * @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 * @@ -436,7 +438,7 @@ * @author Piotr Klaban <makler@man.torun.pl> * @since Numbers_Words 0.4 */ - function toCurrencyWords($int_curr, $decimal, $fraction = false) { + 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; @@ -447,7 +449,11 @@ $ret .= $this->_sep . $curr_names[0][$lev]; if ($fraction !== false) { - $ret .= $this->_sep . trim($this->toWords($fraction)); + 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]; } http://cvs.php.net/diff.php/pear/Numbers_Words/Words/lang.pt_BR.php?r1=1.3&r2=1.4&ty=u Index: pear/Numbers_Words/Words/lang.pt_BR.php diff -u pear/Numbers_Words/Words/lang.pt_BR.php:1.3 pear/Numbers_Words/Words/lang.pt_BR.php:1.4 --- pear/Numbers_Words/Words/lang.pt_BR.php:1.3 Fri Oct 22 03:31:52 2004 +++ pear/Numbers_Words/Words/lang.pt_BR.php Sun Sep 18 15:52:22 2005 @@ -17,7 +17,7 @@ // | Authors: Marcelo Subtil Marcal <jason@conectiva.com.br>, Mario H.C.T. <mariolinux@mitus.com.br> // +----------------------------------------------------------------------+ // -// $Id: lang.pt_BR.php,v 1.3 2004/10/22 07:31:52 makler Exp $ +// $Id: lang.pt_BR.php,v 1.4 2005/09/18 19:52:22 makler Exp $ // // Numbers_Words class extension to spell numbers in Brazilian Portuguese language. // @@ -269,6 +269,8 @@ * @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 * @@ -276,7 +278,7 @@ * @author Mario H.C.T. <mariolinux@mitus.com.br> * @since Numbers_Words 0.10.1 */ - function toCurrencyWords($int_curr, $decimal, $fraction = false) { + function toCurrencyWords($int_curr, $decimal, $fraction = false, $convert_fraction = true) { $int_curr = strtoupper($int_curr); if (!isset($this->_currency_name[$int_curr])){ $int_curr = $this->def_currency; @@ -304,7 +306,11 @@ if ($int_curr == "BRL") $ret .= $this->_sep . 'e'; - $ret .= $this->_sep . trim($this->toWords($fraction)); + 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) { http://cvs.php.net/diff.php/pear/Numbers_Words/Words/lang.ru.php?r1=1.1&r2=1.2&ty=u Index: pear/Numbers_Words/Words/lang.ru.php diff -u pear/Numbers_Words/Words/lang.ru.php:1.1 pear/Numbers_Words/Words/lang.ru.php:1.2 --- pear/Numbers_Words/Words/lang.ru.php:1.1 Thu Sep 2 07:07:59 2004 +++ pear/Numbers_Words/Words/lang.ru.php Sun Sep 18 15:52:22 2005 @@ -18,7 +18,7 @@ // | Andrey Demenev <demenev@on-line.jar.ru> | // +----------------------------------------------------------------------+ // -// $Id: lang.ru.php,v 1.1 2004/09/02 11:07:59 makler Exp $ +// $Id: lang.ru.php,v 1.2 2005/09/18 19:52:22 makler Exp $ // // Numbers_Words class extension to spell numbers in Russian language. // @@ -587,13 +587,15 @@ * @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 <demenev@on-line.jar.ru> */ - function toCurrencyWords($int_curr, $decimal, $fraction = false) + function toCurrencyWords($int_curr, $decimal, $fraction = false, $convert_fraction = true) { $int_curr = strtoupper($int_curr); if (!isset($this->_currency_names[$int_curr])) { @@ -604,7 +606,11 @@ $ret .= $this->_sep . $curr_names[0][$case]; if ($fraction !== false) { - $ret .= $this->_sep . trim($this->_toWordsWithCase($fraction, $case, $curr_names[1][0])); + 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;
« previous php.pear.cvs (#34854) next »