2017 © Pedro Peláez
 

library numbers_words

PEAR::Numbers_Words to PSR-0 compliance. See https://github.com/pear/Numbers_Words

image

lla/numbers_words

PEAR::Numbers_Words to PSR-0 compliance. See https://github.com/pear/Numbers_Words

  • Wednesday, September 7, 2016
  • by ncrypthic
  • Repository
  • 1 Watchers
  • 0 Stars
  • 12 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 46 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

Introduction

This repository is a fork of PEAR::Numbers_Words as composer package with PSR-0 compliance., (*1)

Credits to all previous authors., (*2)

With PEAR::Numbers_Words class you can change an integer number
to simple words. This can be usefull when you need to spell a currency
value e.g. on an invoice.

You can choose between several languages (language files are located
in src/Numbers/Words/Locale directory).

BTW: if you need to change number to currency, use money_format()
PHP function (available since 4.3 (not yet released)). But you must
know that locale LC_MONETARY rules are sometimes unclear.

Getting started

First you need to install lla/numbers_words PEAR package. You can do it (as root) with:, (*3)

composer install ncrypthic/numbers

In your php script you need to use Numbers\Wordsheader file:, (*4)

use \LLA\Numbers\Words;

Then you can call Numbers_Words::fromWords() function with two arguments: integer number (can be a string with digits) and optional locale name (default is en_US):, (*5)

use \LLA\Numbers\Words;

$num   = 12340000000;
$words = Words::fromWords($num,"en_GB");
echo "Num $num in British English is '<b>$words</b>'

<

p>\n";

For this would display:, (*6)

Num 12340000000 in British English is '<b>twelve thousand million three hundred forty million</b>'<p>

There are avaibale the following modules (called by locale name, in alphabetical order):, (*7)

az - Azerbaijani language. Author: Shahriyar Imanov, (*8)

bg - Bulgarian language (in WIN-1251 charset). Author: Kouber Saparev, (*9)

cs - Czech language. Author: Petr 'PePa' Pavel, (*10)

de - German language. Author: Piotr Klaban, (*11)

dk - Danish language. Author: Jesper Veggerby, (*12)

en_100 - Donald Knuth number naming system, in English language. Author: Piotr Klaban, (*13)

en_GB - British English notation of numbers, where one billion is 1000000 times one million. 1000 times million is just 'thousand million' here. I do not use a word billiard here, because English people do not use it often, and even could not know it. Author: Piotr Klaban, (*14)

en_US - American English notation of numbers, where one billion is 1000 times one million Author: Piotr Klaban, (*15)

es - Spanish (Castellano) language. Author: Xavier Noguer, (*16)

es_AR - Argentinian Spanish language. Author: Martin Marrese, (*17)

et - Estonian language. Author: Erkki Saarniit, (*18)

fr - French language. Author: Kouber Saparev, (*19)

fr_BE - French (Belgium) language. Author: Kouber Saparev, Philippe Bajoit, (*20)

he - Hebrew language. Author: Hadar Porat, (*21)

hu_HU - Hungarian language. Author: Nils Homp, (*22)

id - Indonesia language. Authors: Ernas M. Jamil, Arif Rifai Dwiyanto, (*23)

it_IT - Italian language. Authors: Filippo Beltramini, Davide Caironi, (*24)

lt - Lithuanian language. Author: Laurynas Butkus, (*25)

nl - Dutch language. Author: WHAM van Dinter, (*26)

pl - Polish language (in an internet standard charset ISO-8859-2) Author: Piotr Klaban, (*27)

pt_BR - Brazilian Portuguese language. Authors: Marcelo Subtil Marcal, Mario H.C.T., Igor Feghali, (*28)

ro_RO - Romanian language. Author: Bogdan Stancescu, (*29)

ru - Russian language. Author: Andrey Demenev, (*30)

sv - Swedish language. Author: Robin Ericsson, (*31)

tr_TR - Turkish language. Author: Shahriyar Imanov, (*32)

** What if numbers have fraction part?, (*33)

You can split the number by the coma or dot. The example function was provided by Ernas M. Jamil (see below). I do not know if the splitting and concatenating numbers should be supported by Numbers_Words ... Does each language spell numbers with a 'coma'/'koma'? What do you think?, (*34)

use \LLA\Numbers\Words;

function num2word($num, $fract = 0) {

    $num = sprintf("%.".$fract."f", $num);
    $fnum = explode('.', $num);

    $ret =  Words::fromNumber($fnum[0],"id");
    if(!$fract) return $ret;

    $ret .=  ' koma '; // point in english
    $ret .= Words::fromNumber($fnum[1],"id");

    return $ret;
}

** How to convert decimal part and not fraction part of the currency value?, (*35)

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':, (*36)

use \LLA\Numbers\Words;
use \LLA\Numbers\Words\Locale\en\GB;

$obj = new GB();
$convert_fraction = false;
print $obj->toCurrencyWords('GBP', '31', '01', $convert_fraction) . "\n";

** How to write new Language Files:, (*37)

Just copy existing en_US or en_GB etc. file into src/LLA/Numbers/Words/Locale/{your_country/locale code}.php and translate digits, numbers, tousands to your language. Then please send it to the author to the address makler@man.torun.pl., (*38)

** Credits, (*39)

All changes from other people are desrcribed with details in ChangeLog. There are also names of the people who send me patches etc. Authors of the language files are mentioned in the language files directly as the author., (*40)

The Versions

07/09 2016

dev-master

9999999-dev https://github.com/ncrypthic/Numbers_Words

PEAR::Numbers_Words to PSR-0 compliance. See https://github.com/pear/Numbers_Words

  Sources   Download

PHP-3.01

The Requires

  • php >=5.4.20

 

The Development Requires

by Marcelo Subtil Marcal
by Kouber Saparev
by Igor Feghali
by Hadar Porat
by Piotr Klaban
by Lim Afriyadi

numbers

07/09 2016

1.0.1

1.0.1.0 https://github.com/ncrypthic/Numbers_Words

PEAR::Numbers_Words to PSR-0 compliance. See https://github.com/pear/Numbers_Words

  Sources   Download

PHP-3.01

The Requires

  • php >=5.4.20

 

The Development Requires

by Marcelo Subtil Marcal
by Kouber Saparev
by Igor Feghali
by Hadar Porat
by Piotr Klaban
by Lim Afriyadi

numbers

30/08 2016

1.0.0

1.0.0.0 https://github.com/ncrypthic/Numbers_Words

PEAR::Numbers_Words to PSR-0 compliance. See https://github.com/pear/Numbers_Words

  Sources   Download

PHP-3.01

The Requires

  • php >=5.4.20

 

The Development Requires

by Marcelo Subtil Marcal
by Kouber Saparev
by Igor Feghali
by Hadar Porat
by Piotr Klaban
by Lim Afriyadi

numbers

03/11 2014

v0.18.1

0.18.1.0 https://github.com/pear/Numbers_Words

Allows converting numbers written in arabic digits to words in several languages. You can convert an integer between -infinity and infinity.

  Sources   Download

PHP-3.01

The Requires

 

The Development Requires

by Marcelo Subtil Marcal
by Kouber Saparev
by Igor Feghali
by Hadar Porat
by Piotr Klaban

numbers

29/07 2014

v0.18.0

0.18.0.0 https://github.com/pear/Numbers_Words

Allows converting numbers written in arabic digits to words in several languages. You can convert an integer between -infinity and infinity.

  Sources   Download

PHP-3.01

The Requires

 

The Development Requires

by Marcelo Subtil Marcal
by Kouber Saparev
by Igor Feghali
by Hadar Porat
by Piotr Klaban

numbers