cvs: pear /Numbers_Words ChangeLog /Numbers_Words/Words lang.en_GB.php lang.en_US.php lang.he.php lang.hu_HU.php
| From: | Piotr Klaban | Date: | Sun, 18 Sep 2005 18:52:37 +0000 |
| Subject: | cvs: pear /Numbers_Words ChangeLog /Numbers_Words/Words lang.en_GB.php lang.en_US.php lang.he.php lang.hu_HU.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-34851@lists.php.net to get a copy of this message | ||
makler Sun Sep 18 14:52:37 2005 EDT
Modified files:
/pear/Numbers_Words ChangeLog
/pear/Numbers_Words/Words lang.en_GB.php lang.en_US.php lang.he.php
lang.hu_HU.php
Log:
Fixed plural of pence in en_US (bug #4651) and added toCurrency() method to en_GB language file
(bug #4652).
http://cvs.php.net/diff.php/pear/Numbers_Words/ChangeLog?r1=1.8&r2=1.9&ty=u Index: pear/Numbers_Words/ChangeLog diff -u pear/Numbers_Words/ChangeLog:1.8 pear/Numbers_Words/ChangeLog:1.9 --- pear/Numbers_Words/ChangeLog:1.8 Wed Mar 9 02:29:19 2005 +++ pear/Numbers_Words/ChangeLog Sun Sep 18 14:52:36 2005 @@ -1,3 +1,6 @@ +2005-09-19 + * 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). http://cvs.php.net/diff.php/pear/Numbers_Words/Words/lang.en_GB.php?r1=1.2&r2=1.3&ty=u Index: pear/Numbers_Words/Words/lang.en_GB.php diff -u pear/Numbers_Words/Words/lang.en_GB.php:1.2 pear/Numbers_Words/Words/lang.en_GB.php:1.3 --- pear/Numbers_Words/Words/lang.en_GB.php:1.2 Thu Sep 2 07:07:59 2004 +++ pear/Numbers_Words/Words/lang.en_GB.php Sun Sep 18 14:52:37 2005 @@ -17,7 +17,7 @@ // | Authors: Piotr Klaban <makler@man.torun.pl> | // +----------------------------------------------------------------------+ // -// $Id: lang.en_GB.php,v 1.2 2004/09/02 11:07:59 makler Exp $ +// $Id: lang.en_GB.php,v 1.3 2005/09/18 18:52:37 makler Exp $ // // Numbers_Words class extension to spell numbers in British English language. // @@ -124,6 +124,62 @@ */ 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() @@ -303,6 +359,60 @@ return $ret; } // }}} + // {{{ toCurrency() + + /** + * 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. + * + * @return string The corresponding word representation for the currency + * + * @access public + * @author Piotr Klaban <makler@man.torun.pl> + * @since Numbers_Words 0.13.1 + */ + function toCurrencyWords($int_curr, $decimal, $fraction = false) { + $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) { + $ret .= $this->_sep . trim($this->toWords($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; + } + // }}} + + } ?> http://cvs.php.net/diff.php/pear/Numbers_Words/Words/lang.en_US.php?r1=1.3&r2=1.4&ty=u Index: pear/Numbers_Words/Words/lang.en_US.php diff -u pear/Numbers_Words/Words/lang.en_US.php:1.3 pear/Numbers_Words/Words/lang.en_US.php:1.4 --- pear/Numbers_Words/Words/lang.en_US.php:1.3 Mon Feb 28 08:22:51 2005 +++ pear/Numbers_Words/Words/lang.en_US.php Sun Sep 18 14:52:37 2005 @@ -17,7 +17,7 @@ // | Authors: Piotr Klaban <makler@man.torun.pl> | // +----------------------------------------------------------------------+ // -// $Id: lang.en_US.php,v 1.3 2005/02/28 13:22:51 makler Exp $ +// $Id: lang.en_US.php,v 1.4 2005/09/18 18:52:37 makler Exp $ // // Numbers_Words class extension to spell numbers in American English language. // @@ -240,7 +240,7 @@ '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')), + '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')), @@ -270,7 +270,7 @@ * @var string * @access public */ - var $def_currency = 'USD'; // Polish zloty + var $def_currency = 'USD'; // American dollar // }}} // {{{ toWords() http://cvs.php.net/diff.php/pear/Numbers_Words/Words/lang.he.php?r1=1.2&r2=1.3&ty=u Index: pear/Numbers_Words/Words/lang.he.php diff -u pear/Numbers_Words/Words/lang.he.php:1.2 pear/Numbers_Words/Words/lang.he.php:1.3 --- pear/Numbers_Words/Words/lang.he.php:1.2 Mon Feb 28 08:35:31 2005 +++ pear/Numbers_Words/Words/lang.he.php Sun Sep 18 14:52:37 2005 @@ -17,7 +17,7 @@ // | Authors: Hadar Porat | // +----------------------------------------------------------------------+ // -// $Id: lang.he.php,v 1.2 2005/02/28 13:35:31 makler Exp $ +// $Id: lang.he.php,v 1.3 2005/09/18 18:52:37 makler Exp $ // // Numbers_Words class extension to spell numbers in Hebrew language. // @@ -257,7 +257,7 @@ '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')), + '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')), http://cvs.php.net/diff.php/pear/Numbers_Words/Words/lang.hu_HU.php?r1=1.3&r2=1.4&ty=u Index: pear/Numbers_Words/Words/lang.hu_HU.php diff -u pear/Numbers_Words/Words/lang.hu_HU.php:1.3 pear/Numbers_Words/Words/lang.hu_HU.php:1.4 --- pear/Numbers_Words/Words/lang.hu_HU.php:1.3 Mon Feb 28 08:22:51 2005 +++ pear/Numbers_Words/Words/lang.hu_HU.php Sun Sep 18 14:52:37 2005 @@ -17,7 +17,7 @@ // | Nils Homp (Hungarian version) | // +----------------------------------------------------------------------+ // -// $Id: lang.hu_HU.php,v 1.3 2005/02/28 13:22:51 makler Exp $ +// $Id: lang.hu_HU.php,v 1.4 2005/09/18 18:52:37 makler Exp $ // // Numbers_Words class extension to spell numbers in Hungarian language. // NOTE: toCurrency() was not localized and is from the en_US class. @@ -148,7 +148,7 @@ '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')), + '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')),
http://cvs.php.net/diff.php/pear/Numbers_Words/ChangeLog?r1=1.8&r2=1.9&ty=u Index: pear/Numbers_Words/ChangeLog diff -u pear/Numbers_Words/ChangeLog:1.8 pear/Numbers_Words/ChangeLog:1.9 --- pear/Numbers_Words/ChangeLog:1.8 Wed Mar 9 02:29:19 2005 +++ pear/Numbers_Words/ChangeLog Sun Sep 18 14:52:36 2005 @@ -1,3 +1,6 @@ +2005-09-19 + * 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). http://cvs.php.net/diff.php/pear/Numbers_Words/Words/lang.en_GB.php?r1=1.2&r2=1.3&ty=u Index: pear/Numbers_Words/Words/lang.en_GB.php diff -u pear/Numbers_Words/Words/lang.en_GB.php:1.2 pear/Numbers_Words/Words/lang.en_GB.php:1.3 --- pear/Numbers_Words/Words/lang.en_GB.php:1.2 Thu Sep 2 07:07:59 2004 +++ pear/Numbers_Words/Words/lang.en_GB.php Sun Sep 18 14:52:37 2005 @@ -17,7 +17,7 @@ // | Authors: Piotr Klaban <makler@man.torun.pl> | // +----------------------------------------------------------------------+ // -// $Id: lang.en_GB.php,v 1.2 2004/09/02 11:07:59 makler Exp $ +// $Id: lang.en_GB.php,v 1.3 2005/09/18 18:52:37 makler Exp $ // // Numbers_Words class extension to spell numbers in British English language. // @@ -124,6 +124,62 @@ */ 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() @@ -303,6 +359,60 @@ return $ret; } // }}} + // {{{ toCurrency() + + /** + * 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. + * + * @return string The corresponding word representation for the currency + * + * @access public + * @author Piotr Klaban <makler@man.torun.pl> + * @since Numbers_Words 0.13.1 + */ + function toCurrencyWords($int_curr, $decimal, $fraction = false) { + $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) { + $ret .= $this->_sep . trim($this->toWords($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; + } + // }}} + + } ?> http://cvs.php.net/diff.php/pear/Numbers_Words/Words/lang.en_US.php?r1=1.3&r2=1.4&ty=u Index: pear/Numbers_Words/Words/lang.en_US.php diff -u pear/Numbers_Words/Words/lang.en_US.php:1.3 pear/Numbers_Words/Words/lang.en_US.php:1.4 --- pear/Numbers_Words/Words/lang.en_US.php:1.3 Mon Feb 28 08:22:51 2005 +++ pear/Numbers_Words/Words/lang.en_US.php Sun Sep 18 14:52:37 2005 @@ -17,7 +17,7 @@ // | Authors: Piotr Klaban <makler@man.torun.pl> | // +----------------------------------------------------------------------+ // -// $Id: lang.en_US.php,v 1.3 2005/02/28 13:22:51 makler Exp $ +// $Id: lang.en_US.php,v 1.4 2005/09/18 18:52:37 makler Exp $ // // Numbers_Words class extension to spell numbers in American English language. // @@ -240,7 +240,7 @@ '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')), + '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')), @@ -270,7 +270,7 @@ * @var string * @access public */ - var $def_currency = 'USD'; // Polish zloty + var $def_currency = 'USD'; // American dollar // }}} // {{{ toWords() http://cvs.php.net/diff.php/pear/Numbers_Words/Words/lang.he.php?r1=1.2&r2=1.3&ty=u Index: pear/Numbers_Words/Words/lang.he.php diff -u pear/Numbers_Words/Words/lang.he.php:1.2 pear/Numbers_Words/Words/lang.he.php:1.3 --- pear/Numbers_Words/Words/lang.he.php:1.2 Mon Feb 28 08:35:31 2005 +++ pear/Numbers_Words/Words/lang.he.php Sun Sep 18 14:52:37 2005 @@ -17,7 +17,7 @@ // | Authors: Hadar Porat | // +----------------------------------------------------------------------+ // -// $Id: lang.he.php,v 1.2 2005/02/28 13:35:31 makler Exp $ +// $Id: lang.he.php,v 1.3 2005/09/18 18:52:37 makler Exp $ // // Numbers_Words class extension to spell numbers in Hebrew language. // @@ -257,7 +257,7 @@ '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')), + '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')), http://cvs.php.net/diff.php/pear/Numbers_Words/Words/lang.hu_HU.php?r1=1.3&r2=1.4&ty=u Index: pear/Numbers_Words/Words/lang.hu_HU.php diff -u pear/Numbers_Words/Words/lang.hu_HU.php:1.3 pear/Numbers_Words/Words/lang.hu_HU.php:1.4 --- pear/Numbers_Words/Words/lang.hu_HU.php:1.3 Mon Feb 28 08:22:51 2005 +++ pear/Numbers_Words/Words/lang.hu_HU.php Sun Sep 18 14:52:37 2005 @@ -17,7 +17,7 @@ // | Nils Homp (Hungarian version) | // +----------------------------------------------------------------------+ // -// $Id: lang.hu_HU.php,v 1.3 2005/02/28 13:22:51 makler Exp $ +// $Id: lang.hu_HU.php,v 1.4 2005/09/18 18:52:37 makler Exp $ // // Numbers_Words class extension to spell numbers in Hungarian language. // NOTE: toCurrency() was not localized and is from the en_US class. @@ -148,7 +148,7 @@ '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')), + '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')),