[php-pear-Numbers-Words] update to 0.18.0 - add provide php-composer(pear/numbers_words) - add dependency on php-pear(phpsecl
Remi Collet
remi at fedoraproject.org
Sat Nov 1 07:44:21 UTC 2014
commit 8154973088998cf68c5084639933ca0cbb03d44a
Author: Remi Collet <remi at fedoraproject.org>
Date: Sat Nov 1 08:44:23 2014 +0100
update to 0.18.0
- add provide php-composer(pear/numbers_words)
- add dependency on php-pear(phpseclib.sourceforge.net/Math_BigInteger)
- open https://pear.php.net/bugs/20435 missing files
.gitignore | 3 +-
IN.php | 417 ++++++++++++++++++++++++++
PHP-LICENSE-3.01 | 68 -----
RO.php | 699 +++++++++++++++++++++++++++++++++++++++++++
lv.php | 319 ++++++++++++++++++++
php-pear-Numbers-Words.spec | 65 +++-
sources | 2 +-
7 files changed, 1486 insertions(+), 87 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index b1c9d57..e7e90ad 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,7 @@
package-*.xml
-*spec~
+clog
Numbers_Words-0.16.1.tgz
Numbers_Words-0.16.2.tgz
/Numbers_Words-0.16.3.tgz
/Numbers_Words-0.16.4.tgz
+/Numbers_Words-0.18.0.tgz
diff --git a/IN.php b/IN.php
new file mode 100644
index 0000000..0730e10
--- /dev/null
+++ b/IN.php
@@ -0,0 +1,417 @@
+<?php
+/**
+ * Numbers_Words
+ *
+ * PHP version 4
+ *
+ * Copyright (c) 1997-2006 The PHP Group
+ *
+ * This source file is subject to version 3.01 of the PHP license,
+ * that is bundled with this package in the file LICENSE, and is
+ * available at through the world-wide-web at
+ * http://www.php.net/license/3_01.txt
+ * If you did not receive a copy of the PHP license and are unable to
+ * obtain it through the world-wide-web, please send a note to
+ * license at php.net so we can mail you a copy immediately.
+ *
+ * @category Numbers
+ * @package Numbers_Words
+ * @author Piotr Klaban <makler at man.torun.pl>
+ * @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 Indian English.
+ *
+ * @author Abhinav Nayak
+ * @package Numbers_Words
+ */
+
+/**
+ * Include needed files
+ */
+require_once "Numbers/Words.php";
+
+/**
+ * Class for translating numbers into Indian English.
+ *
+ * @category Numbers
+ * @package Numbers_Words
+ * @author Abhinav Nayak <abhinav at nayakweb.in>
+ * @license PHP 3.01 http://www.php.net/license/3_01.txt
+ * @link http://pear.php.net/package/Numbers_Words
+ */
+class Numbers_Words_Locale_en_IN extends Numbers_Words
+{
+
+ // {{{ properties
+
+ /**
+ * Locale name
+ * @var string
+ * @access public
+ */
+ var $locale = 'en_IN';
+
+ /**
+ * Language name in English
+ * @var string
+ * @access public
+ */
+ var $lang = 'Indian English';
+
+ /**
+ * Native language name
+ * @var string
+ * @access public
+ */
+ var $lang_native = 'Indian 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'),
+ 5 => array('Lakh'),
+ 7 => array('Crore'),
+ 9 => array('Hundred Crore'),
+ 11 => array('Thousand Crore')
+ );
+
+ /**
+ * 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')),
+ 'INR' => array(array('Indian Rupees'), array('Paise')),
+ '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 = 'INR'; // Indian Rupee
+
+ // }}}
+ // {{{ _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 <makler at man.torun.pl>
+ * @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 <makler at man.torun.pl>
+ * @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;
+ }
+ // }}}
+
+}
\ No newline at end of file
diff --git a/RO.php b/RO.php
new file mode 100644
index 0000000..3236874
--- /dev/null
+++ b/RO.php
@@ -0,0 +1,699 @@
+<?php
+/**
+ * Numbers_Words
+ *
+ * PHP version 4
+ *
+ * Copyright (c) 1997-2006 The PHP Group
+ *
+ * This source file is subject to version 3.01 of the PHP license,
+ * that is bundled with this package in the file LICENSE, and is
+ * available at through the world-wide-web at
+ * http://www.php.net/license/3_01.txt
+ * If you did not receive a copy of the PHP license and are unable to
+ * obtain it through the world-wide-web, please send a note to
+ * license at php.net so we can mail you a copy immediately.
+ *
+ * @category Numbers
+ * @package Numbers_Words
+ * @author Bogdan Stăncescu <bogdan at moongate.ro>
+ * @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 Romanian (Romania) with the correct diacritical signs (commas).
+ *
+ * @category Numbers
+ * @package Numbers_Words
+ * @author Bogdan Stăncescu <bogdan at moongate.ro>
+ * @license PHP 3.01 http://www.php.net/license/3_01.txt
+ * @link http://pear.php.net/package/Numbers_Words
+ */
+class Numbers_Words_Locale_ro_RO extends Numbers_Words
+{
+
+ // {{{ properties
+
+ /**
+ * Locale name.
+ * @var string
+ * @access public
+ */
+ var $locale = 'ro_RO';
+
+ /**
+ * Language name in English.
+ * @var string
+ * @access public
+ */
+ var $lang = 'Romanian';
+
+ /**
+ * Native language name.
+ * @var string
+ * @access public
+ */
+ var $lang_native = 'Română';
+
+ /**
+ * Anything higher than this is few or many
+ * @var integer
+ * @access private
+ */
+ var $_thresh_few=1;
+
+ /**
+ * Anything higher than this is many
+ * @var integer
+ * @access private
+ */
+ var $_thresh_many=19;
+
+ /**
+ * The words for some numbers.
+ * @var string
+ * @access private
+ */
+ var $_numbers = array(
+ 'zero', // 0
+ array( // 1
+ array( // masculine
+ 'un', // article
+ 'unu', // noun
+ ),
+ array( // feminine
+ 'o', // article
+ 'una', // noun
+ ),
+ 'un', // neutral
+ 'unu', // abstract (stand-alone cardinal)
+ ),
+ array( // 2
+ 'doi', // masculine and abstract
+ 'două', // feminine and neutral
+ ),
+ 'trei', // 3
+ 'patru', // 4
+ 'cinci', // 5
+ 'șase', // 6
+ 'șapte', // 7
+ 'opt', // 8
+ 'nouă', // 9
+ 'zece', // 10
+ 'unsprezece', // 11
+ array( // 12
+ 'doisprezece', // masculine and abstract
+ 'douăsprezece', // feminine and abstract
+ ),
+ 'treisprezece', // 13
+ 'paisprezece', // 14
+ 'cincisprezece', // 15
+ 'șaisprezece', // 16
+ 'șaptesprezece', // 17
+ 'optsprezece', // 18
+ 'nouăsprezece', // 19
+ 'douăzeci', // 20
+ 30=>'treizeci', // 30
+ 40=>'patruzeci', // 40
+ 50=>'cincizeci', // 50
+ 60=>'șaizeci', // 60
+ 70=>'șaptezeci', // 70
+ 80=>'optzeci', // 80
+ 90=>'nouăzeci', // 90
+ );
+
+ /**
+ * The word for infinity.
+ * @var string
+ * @access private
+ */
+ var $_infinity = 'infinit';
+
+ /**
+ * The word for the "and" language construct.
+ * @var string
+ * @access private
+ */
+ var $_and = 'și';
+
+ /**
+ * The word separator.
+ * @var string
+ * @access private
+ */
+ var $_sep = ' ';
+
+ /**
+ * Some currency names (as nouns, see {@link _toWords()} in Romanian
+ * @access private
+ */
+ var $_currency_names = array(
+ 'AUD' => array(
+ array('dolar australian', 'dolari australieni', Numbers_Words::GENDER_MASCULINE),
+ array('cent', 'cenți', Numbers_Words::GENDER_MASCULINE),
+ ),
+ 'CAD' => array(
+ array('dolar canadian', 'dolari canadieni', Numbers_Words::GENDER_MASCULINE),
+ array('cent', 'cenți', Numbers_Words::GENDER_MASCULINE),
+ ),
+ 'CHF' => array(
+ array('franc elvețian', 'franci elvețieni', Numbers_Words::GENDER_MASCULINE),
+ array('cent', 'cenți', Numbers_Words::GENDER_MASCULINE),
+ ),
+ 'CZK' => array(
+ array('coroană cehă', 'coroane cehe', Numbers_Words::GENDER_FEMININE),
+ array('haler', 'haleri', Numbers_Words::GENDER_MASCULINE),
+ ),
+ 'EUR' => array(
+ array('euro', 'euro', Numbers_Words::GENDER_MASCULINE),
+ array('cent', 'cenți', Numbers_Words::GENDER_MASCULINE),
+ ),
+ 'GBP' => array(
+ array('liră sterlină', 'lire sterline', Numbers_Words::GENDER_FEMININE),
+ array('penny', 'penny', Numbers_Words::GENDER_MASCULINE),
+ ),
+ 'HUF' => array(
+ array('forint', 'forinți', Numbers_Words::GENDER_MASCULINE),
+ array('filer', 'fileri', Numbers_Words::GENDER_MASCULINE),
+ ),
+ 'JPY' => array(
+ array('yen', 'yeni', Numbers_Words::GENDER_MASCULINE),
+ array('sen', 'seni', Numbers_Words::GENDER_MASCULINE),
+ ),
+ 'PLN' => array(
+ array('zlot', 'zloți', Numbers_Words::GENDER_MASCULINE),
+ array('gros', 'grosi', Numbers_Words::GENDER_MASCULINE),
+ ),
+ 'ROL' => array(
+ array('leu', 'lei', Numbers_Words::GENDER_MASCULINE),
+ array('ban', 'bani', Numbers_Words::GENDER_MASCULINE),
+ ),
+ 'RON' => array(
+ array('leu', 'lei', Numbers_Words::GENDER_MASCULINE),
+ array('ban', 'bani', Numbers_Words::GENDER_MASCULINE),
+ ),
+ 'RUB' => array(
+ array('rublă', 'ruble', Numbers_Words::GENDER_FEMININE),
+ array('copeică', 'copeici', Numbers_Words::GENDER_FEMININE),
+ ),
+ 'SKK' => array(
+ array('coroană slovacă', 'coroane slovace', Numbers_Words::GENDER_FEMININE),
+ array('haler', 'haleri', Numbers_Words::GENDER_MASCULINE),
+ ),
+ 'TRL' => array(
+ array('liră turcească', 'lire turcești', Numbers_Words::GENDER_FEMININE),
+ array('kuruș', 'kuruși', Numbers_Words::GENDER_MASCULINE),
+ ),
+ 'USD' => array(
+ array('dolar american', 'dolari americani', Numbers_Words::GENDER_MASCULINE),
+ array('cent', 'cenți', Numbers_Words::GENDER_MASCULINE),
+ ),
+ );
+
+ /**
+ * The default currency name
+ * @var string
+ * @access public
+ */
+ var $def_currency = 'RON'; // Romanian leu
+
+ /**
+ * The particle added for many items (>=20)
+ */
+ var $_many_part='de';
+
+ /**
+ * The word for the minus sign.
+ * @var string
+ * @access private
+ */
+ var $_minus = 'minus'; // minus sign
+
+ /**
+ * The suffixes for exponents (singular).
+ * @var array
+ * @access private
+ */
+ var $_exponent = array(
+ 0 => '',
+ 2 => array('sută','sute',Numbers_Words::GENDER_FEMININE),
+ 3 => array('mie','mii',Numbers_Words::GENDER_FEMININE),
+ 6 => array('milion','milioane',Numbers_Words::GENDER_NEUTER),
+ 9 => array('miliard','miliarde',Numbers_Words::GENDER_NEUTER),
+ 12 => array('trilion','trilioane',Numbers_Words::GENDER_NEUTER),
+ 15 => array('cvadrilion','cvadrilioane',Numbers_Words::GENDER_NEUTER),
+ 18 => array('cvintilion','cvintilioane',Numbers_Words::GENDER_NEUTER),
+ 21 => array('sextilion','sextilioane',Numbers_Words::GENDER_NEUTER),
+ 24 => array('septilion','septilioane',Numbers_Words::GENDER_NEUTER),
+ 27 => array('octilion','octilioane',Numbers_Words::GENDER_NEUTER),
+ 30 => array('nonilion','nonilioane',Numbers_Words::GENDER_NEUTER),
+ 33 => array('decilion','decilioane',Numbers_Words::GENDER_NEUTER),
+ 36 => array('undecilion','undecilioane',Numbers_Words::GENDER_NEUTER),
+ 39 => array('dodecilion','dodecilioane',Numbers_Words::GENDER_NEUTER),
+ 42 => array('tredecilion','tredecilioane',Numbers_Words::GENDER_NEUTER),
+ 45 => array('cvadrodecilion','cvadrodecilioane',Numbers_Words::GENDER_NEUTER),
+ 48 => array('cvindecilion','cvindecilioane',Numbers_Words::GENDER_NEUTER),
+ 51 => array('sexdecilion','sexdecilioane',Numbers_Words::GENDER_NEUTER),
+ 54 => array('septdecilion','septdecilioane',Numbers_Words::GENDER_NEUTER),
+ 57 => array('octodecilion','octodecilioane',Numbers_Words::GENDER_NEUTER),
+ 60 => array('novemdecilion','novemdecilioane',Numbers_Words::GENDER_NEUTER),
+ 63 => array('vigintilion','vigintilioane',Numbers_Words::GENDER_NEUTER),
+ 66 => array('unvigintilion','unvigintilioane',Numbers_Words::GENDER_NEUTER),
+ 69 => array('dovigintilion','dovigintilioane',Numbers_Words::GENDER_NEUTER),
+ 72 => array('trevigintilion','trevigintilioane',Numbers_Words::GENDER_NEUTER),
+ 75 => array('cvadrovigintilion','cvadrovigintilioane',Numbers_Words::GENDER_NEUTER),
+ 78 => array('cvinvigintilion','cvinvigintilioane',Numbers_Words::GENDER_NEUTER),
+ 81 => array('sexvigintilion','sexvigintilioane',Numbers_Words::GENDER_NEUTER),
+ 84 => array('septvigintilion','septvigintilioane',Numbers_Words::GENDER_NEUTER),
+ 87 => array('octvigintilion','octvigintilioane',Numbers_Words::GENDER_NEUTER),
+ 90 => array('novemvigintilion','novemvigintilioane',Numbers_Words::GENDER_NEUTER),
+ 93 => array('trigintilion','trigintilioane',Numbers_Words::GENDER_NEUTER),
+ 96 => array('untrigintilion','untrigintilioane',Numbers_Words::GENDER_NEUTER),
+ 99 => array('dotrigintilion','dotrigintilioane',Numbers_Words::GENDER_NEUTER),
+ 102 => array('trestrigintilion','trestrigintilioane',Numbers_Words::GENDER_NEUTER),
+ 105 => array('cvadrotrigintilion','cvadrotrigintilioane',Numbers_Words::GENDER_NEUTER),
+ 108 => array('cvintrigintilion','cvintrigintilioane',Numbers_Words::GENDER_NEUTER),
+ 111 => array('sextrigintilion','sextrigintilioane',Numbers_Words::GENDER_NEUTER),
+ 114 => array('septentrigintilion','septentrigintilioane',Numbers_Words::GENDER_NEUTER),
+ 117 => array('octotrigintilion','octotrigintilioane',Numbers_Words::GENDER_NEUTER),
+ 120 => array('novemtrigintilion','novemtrigintilioane',Numbers_Words::GENDER_NEUTER),
+ 123 => array('cvadragintilion','cvadragintilioane',Numbers_Words::GENDER_NEUTER),
+ 126 => array('uncvadragintilion','uncvadragintilioane',Numbers_Words::GENDER_NEUTER),
+ 129 => array('docvadragintilion','docvadragintilioane',Numbers_Words::GENDER_NEUTER),
+ 132 => array('trecvadragintilion','trecvadragintilioane',Numbers_Words::GENDER_NEUTER),
+ 135 => array('cvadrocvadragintilion','cvadrocvadragintilioane',Numbers_Words::GENDER_NEUTER),
+ 138 => array('cvincvadragintilion','cvincvadragintilioane',Numbers_Words::GENDER_NEUTER),
+ 141 => array('sexcvadragintilion','sexcvadragintilioane',Numbers_Words::GENDER_NEUTER),
+ 144 => array('septencvadragintilion','septencvadragintilioane',Numbers_Words::GENDER_NEUTER),
+ 147 => array('octocvadragintilion','octocvadragintilioane',Numbers_Words::GENDER_NEUTER),
+ 150 => array('novemcvadragintilion','novemcvadragintilioane',Numbers_Words::GENDER_NEUTER),
+ 153 => array('cvincvagintilion','cvincvagintilioane',Numbers_Words::GENDER_NEUTER),
+ 156 => array('uncvincvagintilion','uncvincvagilioane',Numbers_Words::GENDER_NEUTER),
+ 159 => array('docvincvagintilion','docvincvagintilioane',Numbers_Words::GENDER_NEUTER),
+ 162 => array('trecvincvagintilion','trecvincvagintilioane',Numbers_Words::GENDER_NEUTER),
+ 165 => array('cvadrocvincvagintilion','cvadrocvincvagintilioane',Numbers_Words::GENDER_NEUTER),
+ 168 => array('cvincvincvagintilion','cvincvincvagintilioane',Numbers_Words::GENDER_NEUTER),
+ 171 => array('sexcvincvagintilion','sexcvincvagintilioane',Numbers_Words::GENDER_NEUTER),
+ 174 => array('septencvincvagintilion','septencvincvagintilioane',Numbers_Words::GENDER_NEUTER),
+ 177 => array('octocvincvagintilion','octocvincvagintilioane',Numbers_Words::GENDER_NEUTER),
+ 180 => array('novemcvincvagintilion','novemcvincvagintilioane',Numbers_Words::GENDER_NEUTER),
+ 183 => array('sexagintilion','sexagintilioane',Numbers_Words::GENDER_NEUTER),
+ 186 => array('unsexagintilion','unsexagintilioane',Numbers_Words::GENDER_NEUTER),
+ 189 => array('dosexagintilion','dosexagintilioane',Numbers_Words::GENDER_NEUTER),
+ 192 => array('tresexagintilion','tresexagintilioane',Numbers_Words::GENDER_NEUTER),
+ 195 => array('cvadrosexagintilion','cvadrosexagintilioane',Numbers_Words::GENDER_NEUTER),
+ 198 => array('cvinsexagintilion','cvinsexagintilioane',Numbers_Words::GENDER_NEUTER),
+ 201 => array('sexsexagintilion','sexsexagintilioane',Numbers_Words::GENDER_NEUTER),
+ 204 => array('septensexagintilion','septensexagintilioane',Numbers_Words::GENDER_NEUTER),
+ 207 => array('octosexagintilion','octosexagintilioane',Numbers_Words::GENDER_NEUTER),
+ 210 => array('novemsexagintilion','novemsexagintilioane',Numbers_Words::GENDER_NEUTER),
+ 213 => array('septuagintilion','septuagintilioane',Numbers_Words::GENDER_NEUTER),
+ 216 => array('unseptuagintilion','unseptuagintilioane',Numbers_Words::GENDER_NEUTER),
+ 219 => array('doseptuagintilion','doseptuagintilioane',Numbers_Words::GENDER_NEUTER),
+ 222 => array('treseptuagintilion','treseptuagintilioane',Numbers_Words::GENDER_NEUTER),
+ 225 => array('cvadroseptuagintilion','cvadroseptuagintilioane',Numbers_Words::GENDER_NEUTER),
+ 228 => array('cvinseptuagintilion','cvinseptuagintilioane',Numbers_Words::GENDER_NEUTER),
+ 231 => array('sexseptuagintilion','sexseptuagintilioane',Numbers_Words::GENDER_NEUTER),
+ 234 => array('septenseptuagintilion','septenseptuagintilioane',Numbers_Words::GENDER_NEUTER),
+ 237 => array('octoseptuagintilion','octoseptuagintilioane',Numbers_Words::GENDER_NEUTER),
+ 240 => array('novemseptuagintilion','novemseptuagintilioane',Numbers_Words::GENDER_NEUTER),
+ 243 => array('octogintilion','octogintilioane',Numbers_Words::GENDER_NEUTER),
+ 246 => array('unoctogintilion','unoctogintilioane',Numbers_Words::GENDER_NEUTER),
+ 249 => array('dooctogintilion','dooctogintilioane',Numbers_Words::GENDER_NEUTER),
+ 252 => array('treoctogintilion','treoctogintilioane',Numbers_Words::GENDER_NEUTER),
+ 255 => array('cvadrooctogintilion','cvadrooctogintilioane',Numbers_Words::GENDER_NEUTER),
+ 258 => array('cvinoctogintilion','cvinoctogintilioane',Numbers_Words::GENDER_NEUTER),
+ 261 => array('sexoctogintilion','sexoctogintilioane',Numbers_Words::GENDER_NEUTER),
+ 264 => array('septoctogintilion','septoctogintilioane',Numbers_Words::GENDER_NEUTER),
+ 267 => array('octooctogintilion','octooctogintilioane',Numbers_Words::GENDER_NEUTER),
+ 270 => array('novemoctogintilion','novemoctogintilioane',Numbers_Words::GENDER_NEUTER),
+ 273 => array('nonagintilion','nonagintilioane',Numbers_Words::GENDER_NEUTER),
+ 276 => array('unnonagintilion','unnonagintilioane',Numbers_Words::GENDER_NEUTER),
+ 279 => array('dononagintilion','dononagintilioane',Numbers_Words::GENDER_NEUTER),
+ 282 => array('trenonagintilion','trenonagintilioane',Numbers_Words::GENDER_NEUTER),
+ 285 => array('cvadrononagintilion','cvadrononagintilioane',Numbers_Words::GENDER_NEUTER),
+ 288 => array('cvinnonagintilion','cvinnonagintilioane',Numbers_Words::GENDER_NEUTER),
+ 291 => array('sexnonagintilion','sexnonagintilioane',Numbers_Words::GENDER_NEUTER),
+ 294 => array('septennonagintilion','septennonagintilioane',Numbers_Words::GENDER_NEUTER),
+ 297 => array('octononagintilion','octononagintilioane',Numbers_Words::GENDER_NEUTER),
+ 300 => array('novemnonagintilion','novemnonagintilioane',Numbers_Words::GENDER_NEUTER),
+ 303 => array('centilion','centilioane',Numbers_Words::GENDER_NEUTER),
+ );
+ // }}}
+
+ // {{{ _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 <kouber at php.net>
+ * @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
+ }
+ // }}}
+
+ // {{{ _get_number_inflection_for_gender()
+ /**
+ * Returns the inflected form of the cardinal according to the noun's gender.
+ *
+ * @param mixed $number_atom A number atom, per {@link $_numbers}
+ * @param array $noun A noun, per {@link _toWords()}
+ * @param boolean $as_noun A flag indicating whether the inflected form should
+ * behave as a noun (true, "unu") or as an article (false, "un")
+ * @return string The inflected form of the number
+ * @access private
+ * @author Bogdan Stăncescu <bogdan at moongate.ro>
+ */
+ function _get_number_inflection_for_gender($number_atom, $noun, $as_noun=false)
+ {
+ if (!is_array($number_atom)) {
+ $num_names=array(
+ $number_atom,
+ $number_atom,
+ $number_atom,
+ $number_atom,
+ );
+ } elseif (count($number_atom)==2) {
+ $num_names=array(
+ $number_atom[0],
+ $number_atom[1],
+ $number_atom[1],
+ $number_atom[0],
+ );
+ } else {
+ $num_names=$number_atom;
+ }
+
+ $num_name=$num_names[$noun[2]];
+ if (!is_array($num_name)) {
+ return $num_name;
+ }
+
+ return $num_name[(int) $as_noun];
+ }
+ // }}}
+
+ // {{{ _get_noun_declension_for_number
+ /**
+ * Returns the noun's declension according to the cardinal's number.
+ *
+ * @param string $plural_rule The plural rule to use, per {@link _get_plural_rule()}
+ * @param array $noun A noun, per {@link _toWords()}
+ * @return string The inflected form of the noun
+ * @access private
+ * @author Bogdan Stăncescu <bogdan at moongate.ro>
+ */
+ function _get_noun_declension_for_number($plural_rule, $noun)
+ {
+ if ($noun[2]==Numbers_Words::GENDER_ABSTRACT) {
+ // Nothing for abstract count
+ return "";
+ }
+
+ if ($plural_rule=='o') {
+ // One
+ return $noun[0];
+ }
+
+ if ($plural_rule=='f') {
+ // Few
+ return $noun[1];
+ }
+
+ // Many
+ return $this->_many_part.$this->_sep.$noun[1];
+ }
+ // }}}
+
+ // {{{ _get_plural_rule()
+ /**
+ * Returns the plural rule to use for a specific number.
+ *
+ * Romanian uses three plural rules (see http://cldr.unicode.org/index/cldr-spec/plural-rules),
+ * namely one ("un om"), few ("doi oameni") and many ("o sută de oameni").
+ * We use the following notation consistently throughout this class for the three rules:
+ * 'o' for one, 'f' for few, and 'm' for many. These three rules are applied depending
+ * on the number of items; see
+ * http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html#ro
+ *
+ */
+ function _get_plural_rule($number)
+ {
+ if ($number==$this->_thresh_few) {
+ // One
+ return 'o';
+ }
+
+ if ($number==0) {
+ // Zero, which behaves like few
+ return 'f';
+ }
+
+ $uz=$number%100;
+
+ if ($uz==0) {
+ // Hundreds behave like many
+ return 'm';
+ }
+
+ if ($uz>$this->_thresh_many) {
+ // Many
+ return 'm';
+ }
+
+ // Below the many threshold, so few
+ return 'f';
+ }
+ // }}}
+
+ // {{{ _showDigitsGroup()
+ /**
+ * Converts a three-digit number to its word representation in Romanian.
+ *
+ * @param integer $num An integer between 1 and 999 inclusive.
+ * @param array $noun The noun representing the items being counted, per {@link _toWords()}
+ * @param boolean $force_noun A flag indicating whether the numeral's inflection should force it behave like a noun
+ * @param boolean $force_plural A flag indicating whether we want to override the plural form (we can't tell if we're processing 1 dollar or 1001 dollars from within this method)
+ *
+ * @return string The words for the given number and the given noun.
+ * @access private
+ * @author Bogdan Stăncescu <bogdan at moongate.ro>
+ */
+ function _showDigitsGroup($num, $noun, $force_noun=false, $force_plural=false)
+ {
+ $ret = '';
+
+ // extract the value of each digit from the three-digit number
+ $u = $num%10; // ones
+ $uz = $num%100; // ones+tens
+ $z = ($num-$u)%100/10; // tens
+ $s = ($num-$z*10-$u)%1000/100; // hundreds
+
+ if ($s) {
+ $ret.=$this->_showDigitsGroup($s, $this->_exponent[2]);
+ if ($uz) {
+ $ret.=$this->_sep;
+ }
+ }
+ if ($uz) {
+ if (isset($this->_numbers[$uz])) {
+ $ret.=$this->_get_number_inflection_for_gender($this->_numbers[$uz], $noun, !$force_noun);
+ } else {
+ if ($z) {
+ $ret.=$this->_numbers[$z*10]; // no accord needed for tens
+ if ($u) {
+ $ret.=$this->_sep.$this->_and.$this->_sep;
+ }
+ }
+ if ($u) {
+ $ret.=$this->_get_number_inflection_for_gender($this->_numbers[$u], $noun, !$force_noun);
+ }
+ }
+ }
+
+ if ($noun[2]==Numbers_Words::GENDER_ABSTRACT) {
+ return $ret;
+ }
+
+ $plural_rule=$this->_get_plural_rule($num);
+ if ($plural_rule=='o' && $force_plural) {
+ $plural_rule='f';
+ }
+
+ return $ret.$this->_sep.$this->_get_noun_declension_for_number($plural_rule, $noun);
+ }
+ // }}}
+
+ // {{{ _toWords()
+
+ /**
+ * Converts a number to its word representation in Romanian
+ *
+ * Romanian uses a complex set of rules for numerals, and a lot of inflections are
+ * interdependent. As such, this class implements an easy means for authors to
+ * count either abstract numbers (in which case the second parameter should be
+ * omitted), or actual nouns. In the latter case, a noun must be provided as an
+ * indexed array containing three values:
+ * 0 => the singular form
+ * 1 => the plural form
+ * 2 => the noun's gender, as one of the following constants:
+ * - Numbers_Words::GENDER_MASCULINE for masculine nouns
+ * - Numbers_Words::GENDER_FEMININE for feminine nouns
+ * - Numbers_Words::GENDER_NEUTER for neuter nouns
+ *
+ * @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
+ * @param array $noun Optionally you can also provide a noun to be formatted accordingly
+ * @return string The corresponding word representation
+ * @access protected
+ * @author Bogdan Stăncescu <bogdan at moongate.ro>
+ */
+ function _toWords($num = 0, $noun = array())
+ {
+ if (empty($noun)) {
+ $noun=array(NULL, NULL, Numbers_Words::GENDER_ABSTRACT);
+ }
+
+ $ret = '';
+
+ // check if $num is a valid non-zero number
+ if (!$num || preg_match('/^-?0+$/', $num) || !preg_match('/^-?\d+$/', $num)) {
+ $ret = $this->_numbers[0];
+ if ($noun[2]!=Numbers_Words::GENDER_ABSTRACT) {
+ $ret .= $this->_sep.$this->_get_noun_declension_for_number('f',$noun);
+ }
+ return $ret;
+ }
+
+ // add a minus sign
+ if (substr($num, 0, 1) == '-') {
+ $ret = $this->_minus . $this->_sep;
+ $num = substr($num, 1);
+ }
+
+ // One is a special case
+ if (abs($num)==1) {
+ $ret = $this->_get_number_inflection_for_gender($this->_numbers[1], $noun);
+ if ($noun[2]!=Numbers_Words::GENDER_ABSTRACT) {
+ $ret .= $this->_sep.$this->_get_noun_declension_for_number('o',$noun);
+ }
+ return $ret;
+ }
+
+ // 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);
+ $showed_noun = false;
+ foreach ($num_groups as $i=>$number) {
+ // what is the corresponding exponent for the current group
+ $pow = $sizeof_numgroups-$i;
+
+ $valid_groups=array();
+
+ // skip processment for empty groups
+ if ($number=='000') {
+ continue;
+ }
+
+ if ($i) {
+ $ret.=$this->_sep;
+ }
+
+ if ($pow-1) {
+ $ret.=$this->_showDigitsGroup($number, $this->_exponent[($pow-1)*3]);
+ } else {
+ $showed_noun = true;
+ $ret.=$this->_showDigitsGroup($number, $noun, false, $num!=1);
+ }
+ }
+ if (!$showed_noun) {
+ $ret.=$this->_sep.$this->_get_noun_declension_for_number('m',$noun); // ALWAYS many
+ }
+
+ return rtrim($ret, $this->_sep);
+ }
+ // }}}
+
+ // {{{ toCurrencyWords()
+
+ /**
+ * Converts a currency value to its word representation
+ * (with monetary units) in Romanian
+ *
+ * @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 Bogdan Stăncescu <bogdan at moongate.ro>
+ */
+ 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_nouns = $this->_currency_names[$int_curr];
+ $ret = $this->_toWords($decimal, $curr_nouns[0]);
+
+ if ($fraction !== false) {
+ $ret .= $this->_sep . $this->_and;
+ if ($convert_fraction) {
+ $ret .= $this->_sep . $this->_toWords($fraction, $curr_nouns[1]);
+ } else {
+ $ret .= $fraction . $this->_sep;
+ $plural_rule = $this->_get_plural_rule($fraction);
+ $this->_get_noun_declension_for_number($curr_nouns[1]);
+ }
+ }
+
+ return $ret;
+ }
+
+ // }}}
+}
diff --git a/lv.php b/lv.php
new file mode 100644
index 0000000..81d0c84
--- /dev/null
+++ b/lv.php
@@ -0,0 +1,319 @@
+<?php
+/**
+ * Numbers_Words
+ *
+ * PHP version 5
+ *
+ * Copyright (c) 1997-2006 The PHP Group
+ *
+ * This source file is subject to version 3.01 of the PHP license,
+ * that is bundled with this package in the file LICENSE, and is
+ * available at through the world-wide-web at
+ * http://www.php.net/license/3_01.txt
+ * If you did not receive a copy of the PHP license and are unable to
+ * obtain it through the world-wide-web, please send a note to
+ * license at php.net so we can mail you a copy immediately.
+ *
+ * @category Numbers
+ * @package Numbers_Words
+ * @author Andrius Virbičianskas <a at ndri.us>
+ * @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 Latvian.
+ *
+ * @author Andrius Virbičianskas. Source from Laurynas Butkus.
+ * @package Numbers_Words
+ */
+
+/**
+ * Include needed files
+ */
+require_once "Numbers/Words.php";
+
+/**
+ * Class for translating numbers into Latvian.
+ *
+ * @category Numbers
+ * @package Numbers_Words
+ * @author Andrius Virbičianskas <a at ndri.us>
+ * @license PHP 3.01 http://www.php.net/license/3_01.txt
+ * @link http://pear.php.net/package/Numbers_Words
+ */
+class Numbers_Words_Locale_lv extends Numbers_Words
+{
+
+ // {{{ properties
+
+ /**
+ * Locale name
+ * @var string
+ * @access public
+ */
+ var $locale = 'lv';
+
+ /**
+ * Language name in English
+ * @var string
+ * @access public
+ */
+ var $lang = 'Latvian';
+
+ /**
+ * Native language name
+ * @var string
+ * @access public
+ */
+ var $lang_native = 'latviešu';
+
+ /**
+ * 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ūkstotis','tūkstoši','tūkstoši'),
+ 6 => array('miljons','miljoni','miljons'),
+ 9 => array('miljards','miljardi','miljardi'),
+ 12 => array('triljons','triljoni','triljoni'),
+ 15 => array('kvadriljons','kvadriljoni','kvadriljoni'),
+ 18 => array('kvintiljons','kvintiljoni','kvintiljoni')
+ );
+
+ /**
+ * The array containing the digits (indexed by the digits themselves).
+ * @var array
+ * @access private
+ */
+ var $_digits = array(
+ 0 => 'nulle', 'viens', 'divi', 'trīs', 'četri',
+ 'pieci', 'seši', 'septiņi', 'astoņi', 'deviņi'
+ );
+
+ /**
+ * The word separator
+ * @var string
+ * @access private
+ */
+ var $_sep = ' ';
+
+ /**
+ * The default currency name
+ * @var string
+ * @access public
+ */
+ var $def_currency = 'Ls';
+
+ // }}}
+ // {{{ _toWords()
+
+ /**
+ * Converts a number to its word representation
+ * in Latvian 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 Andrius Virbičianskas <a at ndri.us>
+ * @since Numbers_Words 0.16.4
+ */
+ 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 . 'simti';
+ } elseif ( $h ) {
+ $ret .= $this->_sep . 'simts';
+ }
+
+ // ten, twenty etc.
+ switch ($t) {
+ case 9:
+ $ret .= $this->_sep . 'deviņdesmit';
+ break;
+
+ case 8:
+ $ret .= $this->_sep . 'astoņdesmit';
+ break;
+
+ case 7:
+ $ret .= $this->_sep . 'septiņdesmit';
+ break;
+
+ case 6:
+ $ret .= $this->_sep . 'sešdesmit';
+ break;
+
+ case 5:
+ $ret .= $this->_sep . 'piecdesmit';
+ break;
+
+ case 4:
+ $ret .= $this->_sep . 'četrdesmit';
+ break;
+
+ case 3:
+ $ret .= $this->_sep . 'trīsdesmit';
+ break;
+
+ case 2:
+ $ret .= $this->_sep . 'divdesmit';
+ break;
+
+ case 1:
+ switch ($d) {
+ case 0:
+ $ret .= $this->_sep . 'desmit';
+ break;
+
+ case 1:
+ $ret .= $this->_sep . 'vienpadsmit';
+ break;
+
+ case 2:
+ $ret .= $this->_sep . 'divpadsmit';
+ break;
+
+ case 3:
+ $ret .= $this->_sep . 'trīspadsmit';
+ break;
+
+ case 4:
+ $ret .= $this->_sep . 'četrpadsmit';
+ break;
+
+ case 5:
+ $ret .= $this->_sep . 'piecpadsmit';
+ break;
+
+ case 6:
+ $ret .= $this->_sep . 'sešpadsmit';
+ break;
+
+ case 7:
+ $ret .= $this->_sep . 'septiņpadsmit';
+ break;
+
+ case 8:
+ $ret .= $this->_sep . 'astoņpadsmit';
+ break;
+
+ case 9:
+ $ret .= $this->_sep . 'deviņpadsmit';
+ 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;
+ }
+
+ 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;
+ }
+ // }}}
+
+}
diff --git a/php-pear-Numbers-Words.spec b/php-pear-Numbers-Words.spec
index 0bd3c76..015960e 100644
--- a/php-pear-Numbers-Words.spec
+++ b/php-pear-Numbers-Words.spec
@@ -1,30 +1,50 @@
+# spec file for php-pear-Numbers-Words
+#
+# Copyright (c) 2010-2014 Remi Collet
+# Copyright (c) 2006-2009 Christopher Stone
+#
+# License: MIT
+# http://opensource.org/licenses/MIT
+#
+# Please, preserve the changelog entries
+#
%{!?pear_metadir: %global pear_metadir %{pear_phpdir}}
-%{!?__pear: %{expand: %%global __pear %{_bindir}/pear}}
+%{!?__pear: %global __pear %{_bindir}/pear}
%global pear_name Numbers_Words
Name: php-pear-Numbers-Words
-Version: 0.16.4
-Release: 7%{?dist}
+Version: 0.18.0
+Release: 1%{?dist}
Summary: Methods for spelling numerals in words
Group: Development/Languages
License: PHP
URL: http://pear.php.net/package/Numbers_Words
Source0: http://pear.php.net/get/%{pear_name}-%{version}.tgz
+# https://pear.php.net/bugs/20435
+Source1: https://raw.githubusercontent.com/pear/Numbers_Words/master/Numbers/Words/Locale/lv.php
+Source2: https://raw.githubusercontent.com/pear/Numbers_Words/master/Numbers/Words/Locale/ro/RO.php
+Source3: https://raw.githubusercontent.com/pear/Numbers_Words/master/Numbers/Words/Locale/en/IN.php
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
-
BuildArch: noarch
BuildRequires: php-pear
# For test suite
-BuildRequires: php-pear(pear.phpunit.de/PHPUnit)
+BuildRequires: php-phpunit-PHPUnit
-Requires: php-pear(PEAR)
-# optional and not yet available
-# Requires: php-pear(Math_BigInteger)
Requires(post): %{__pear}
Requires(postun): %{__pear}
+# From package.xml
+Requires: php(language) >= 5.3.2
+Requires: php-pear(PEAR)
+# Instead of php-pear(Math_BigInteger), same API
+Requires: php-pear(phpseclib.sourceforge.net/Math_BigInteger)
+# From phpcompatinfo report for version 0.18.0
+Requires: php-pcre
+
Provides: php-pear(%{pear_name}) = %{version}
+Provides: php-composer(pear/numbers_words) = %{version}
+
%description
With Numbers_Words class you can convert numbers written in Arabic digits to
@@ -39,6 +59,9 @@ Numbers_Words::toWords() with just a string.
cd %{pear_name}-%{version}
# Package is V2
mv ../package.xml %{name}.xml
+install -Dpm 0644 %{SOURCE1} Numbers/Words/Locale/lv.php
+install -Dpm 0644 %{SOURCE2} Numbers/Words/Locale/ro/RO.php
+install -Dpm 0644 %{SOURCE3} Numbers/Words/Locale/en/IN.php
%build
@@ -47,29 +70,31 @@ cd %{pear_name}-%{version}
%install
-rm -rf $RPM_BUILD_ROOT
+rm -rf %{buildroot}
cd %{pear_name}-%{version}
-%{__pear} install --nodeps --packagingroot $RPM_BUILD_ROOT %{name}.xml
+%{__pear} install --nodeps --packagingroot %{buildroot} %{name}.xml
-# fix wrong-file-end-of-line-encoding
-sed -i 's/\r//' $RPM_BUILD_ROOT%{pear_docdir}/%{pear_name}/README
-sed -i 's/\r//' $RPM_BUILD_ROOT%{pear_docdir}/%{pear_name}/ChangeLog
+# Missing
+install -Dpm 0644 %{SOURCE1} %{buildroot}%{pear_phpdir}/Numbers/Words/Locale/lv.php
+install -Dpm 0644 %{SOURCE2} %{buildroot}%{pear_phpdir}/Numbers/Words/Locale/ro/RO.php
+install -Dpm 0644 %{SOURCE3} %{buildroot}%{pear_phpdir}/Numbers/Words/Locale/en/IN.php
# Clean up unnecessary files
-rm -rf $RPM_BUILD_ROOT%{pear_metadir}/.??*
+rm -rf %{buildroot}%{pear_metadir}/.??*
# Install XML package description
-install -d $RPM_BUILD_ROOT%{pear_xmldir}
-install -pm 644 %{name}.xml $RPM_BUILD_ROOT%{pear_xmldir}
+install -d %{buildroot}%{pear_xmldir}
+install -pm 644 %{name}.xml %{buildroot}%{pear_xmldir}
%check
cd %{pear_name}-%{version}
+sed -e "/encoding='iso-8859-15'/d" -i tests/*php
phpunit tests
%clean
-rm -rf $RPM_BUILD_ROOT
+rm -rf %{buildroot}
%post
@@ -92,6 +117,12 @@ fi
%changelog
+* Sat Nov 1 2014 Remi Collet <remi at fedoraproject.org> - 0.18.0-1
+- update to 0.18.0
+- add provide php-composer(pear/numbers_words)
+- add dependency on php-pear(phpseclib.sourceforge.net/Math_BigInteger)
+- open https://pear.php.net/bugs/20435 missing files
+
* Sat Jun 07 2014 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 0.16.4-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild
diff --git a/sources b/sources
index 5f23569..1cf48bf 100644
--- a/sources
+++ b/sources
@@ -1 +1 @@
-8b710a80794bc162630891a70876d906 Numbers_Words-0.16.4.tgz
+947c230c5b97d78c77ae198e426bb13b Numbers_Words-0.18.0.tgz
More information about the scm-commits
mailing list