2017 © Pedro Peláez
 

library number-to-words

Multi language standalone PHP number to words converter. Fully tested, open for extensions and new languages.

image

kwn/number-to-words

Multi language standalone PHP number to words converter. Fully tested, open for extensions and new languages.

  • Monday, June 18, 2018
  • by kwn
  • Repository
  • 10 Watchers
  • 75 Stars
  • 151,745 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 42 Forks
  • 2 Open issues
  • 23 Versions
  • 16 % Grown

The README.md

PHP Number to words converter

CircleCI Code Climate Test Coverage Latest Stable Version, (*1)

Welcome to number-to-words, a PHP utility that seamlessly transforms numeric values into their corresponding words. Effortlessly convert numbers, such as 123, into expressive and readable formats like "one hundred and twenty-three" with just a few lines of code., (*2)

Installation

Add package to your composer.json by running:, (*3)

$ composer require kwn/number-to-words

Usage

There are two types of number-to-words transformation: number and currency. In order to use a relevant transformer for specific language create an instance of NumberToWords class and call a method that creates a new instance of the desired transformer;, (*4)

Number Transformer

Create a transformer for specific language using the getNumberTransformer('lang') method:, (*5)

use NumberToWords\NumberToWords;

// create the number to words "manager" class
$numberToWords = new NumberToWords();

// build a new number transformer using the RFC 3066 language identifier
$numberTransformer = $numberToWords->getNumberTransformer('en');

Transformer can be used by passing in numeric values to the toWords() method:, (*6)

$numberTransformer->toWords(5120); // outputs "five thousand one hundred twenty"

It can be also used with a static method:, (*7)

NumberToWords::transformNumber('en', 5120); // outputs "five thousand one hundred twenty"

Currency Transformer

Creating a currency transformer works just like a number transformer., (*8)

use NumberToWords\NumberToWords;

// create the number to words "manager" class
$numberToWords = new NumberToWords();

// build a new currency transformer using the RFC 3066 language identifier
$currencyTransformer = $numberToWords->getCurrencyTransformer('en');

Then it can be used passing in numeric values for amount and ISO 4217 currency identifier to the toWords() method:, (*9)

$currencyTransformer->toWords(5099, 'USD'); // outputs "fifty dollars ninety nine cents"

It can be also used with a static method:, (*10)

NumberToWords::transformCurrency('en', 5099, 'USD'); // outputs "fifty dollars ninety nine cents"

Note: The Currency Transformer within this library processes integers; ensure your input amounts are in whole numbers by multiplying any float values by 100 before transformation. For instance, transform 45.67 by using 4567 as the input for accurate currency conversion., (*11)

Available locale

Language Identifier Number Currency Alias
Albanian al + +
Arabic ar + +
Azerbaijani az + +
Belgian French fr_BE + -
Brazilian Portuguese pt_BR + +
Bulgarian bg + +
Czech cs + -
Danish dk + +
Dutch nl + -
English en + +
Estonian et + -
Georgian ka + +
German de + +
French fr + + fr_FR
Hungarian hu + +
Indonesian id + +
Italian it + -
Kurdish ku + -
Lithuanian lt + +
Latvian lv + +
Macedonian mk + -
Malay ms + +
Persian fa + -
Polish pl + +
Romanian ro + +
Serbian sr + +
Slovak sk + +
Spanish es + +
Russian ru + +
Swahili sw + +
Swedish sv + -
Turkish tr + +
Turkmen tk + +
Ukrainian ua + +
Uzbek uz + +
Yoruba yo + +

Contributors

Some transformers were ported from the pear/Numbers_Words library. Others were created by contributors. Thank you!, (*12)

Version 2.x - BC and major changes

  • Dropped support for PHP <7.4.
  • Added typehints for NumberTransformer and CurrencyTransformer interfaces. Now both accept integer numbers only (Albanian language might be affected).
  • Added support for PSR12.

Questions and answers

Q: What should I do if I encounter a bug while using the library?, (*13)

A: If you come across a bug, please open an issue on our GitHub repository. As I may not be proficient in all languages, we encourage users to submit fixes and collaborate to enhance the library's functionality., (*14)

Q: My language is missing. Could it be added?, (*15)

A: There's a high chance I don't know your language. Feel free to implement the missing language and open a pull request. You can use the existing languages as a reference., (*16)

The Versions

18/06 2018

dev-master

9999999-dev

Multi language standalone PHP number to words converter. Fully tested, open for extensions and new languages.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

currency money string number words to angle

18/06 2018

1.5.3

1.5.3.0

Multi language standalone PHP number to words converter. Fully tested, open for extensions and new languages.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

currency money string number words to angle

12/06 2018

1.5.2

1.5.2.0

Multi language standalone PHP number to words converter. Fully tested, open for extensions and new languages.

  Sources   Download

MIT

The Requires

  • php >=5.5

 

The Development Requires

currency money string number words to angle

11/03 2018

1.5.1

1.5.1.0

Multi language standalone PHP number to words converter. Fully tested, open for extensions and new languages.

  Sources   Download

MIT

The Requires

  • php >=5.5

 

The Development Requires

currency money string number words to angle

24/01 2018

1.5.0

1.5.0.0

Multi language standalone PHP number to words converter. Fully tested, open for extensions and new languages.

  Sources   Download

MIT

The Requires

  • php >=5.5

 

The Development Requires

currency money string number words to angle

23/01 2018

1.4.0

1.4.0.0

Multi language standalone PHP number to words converter. Fully tested, open for extensions and new languages.

  Sources   Download

MIT

The Requires

  • php >=5.5

 

The Development Requires

currency money string number words to angle

04/01 2018

1.3.5

1.3.5.0

Multi language standalone PHP number to words converter. Fully tested, open for extensions and new languages.

  Sources   Download

MIT

The Requires

  • php >=5.5

 

The Development Requires

currency money string number words to angle

29/06 2017

dev-russian-language-refactoring

dev-russian-language-refactoring

Multi language standalone PHP number to words converter. Fully tested, open for extensions and new languages.

  Sources   Download

MIT

The Requires

  • php >=5.5

 

The Development Requires

currency money string number words to angle

13/05 2017

1.3.4

1.3.4.0

Multi language standalone PHP number to words converter. Fully tested, open for extensions and new languages.

  Sources   Download

MIT

The Requires

  • php >=5.5

 

The Development Requires

currency money string number words to angle

13/05 2017

1.3.3

1.3.3.0

Multi language standalone PHP number to words converter. Fully tested, open for extensions and new languages.

  Sources   Download

MIT

The Requires

  • php >=5.5

 

The Development Requires

currency money string number words to angle

13/05 2017

1.3.2

1.3.2.0

Multi language standalone PHP number to words converter. Fully tested, open for extensions and new languages.

  Sources   Download

MIT

The Requires

  • php >=5.5

 

The Development Requires

currency money string number words to angle

13/05 2017

1.3.1

1.3.1.0

Multi language standalone PHP number to words converter. Fully tested, open for extensions and new languages.

  Sources   Download

MIT

The Requires

  • php >=5.5

 

The Development Requires

currency money string number words to angle

12/05 2017

1.3.0

1.3.0.0

Multi language standalone PHP number to words converter. Fully tested, open for extensions and new languages.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

currency money string number words to angle

03/05 2017

1.2.2

1.2.2.0

Multi language standalone PHP number to words converter. Fully tested, open for extensions and new languages.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

currency money string number words to angle

06/02 2017

1.2.1

1.2.1.0

Multi language standalone PHP number to words converter. Fully tested, open for extensions and new languages.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

currency money string number words to angle

19/12 2016

1.2.0

1.2.0.0

Multi language standalone PHP number to words converter. Fully tested, open for extensions and new languages.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

currency money string number words to angle

23/11 2016

1.1.1

1.1.1.0

Multi language standalone PHP number to words converter. Fully tested, open for extensions and new languages.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

currency money string number words to angle

02/10 2016

1.1.0

1.1.0.0

Multi language standalone PHP number to words converter. Fully tested, open for extensions and new languages.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

currency money string number words to angle

30/09 2016

1.0.0

1.0.0.0

Multi language standalone PHP number to words converter. Fully tested, open for extensions and new languages.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

currency money string number words to angle

04/05 2016

0.0.4

0.0.4.0

Multilanguage standalone PHP number to words converter library. Fully tested, open for extensions and new languages.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

currency money string number words to angle

14/04 2016

0.0.3

0.0.3.0

Multilanguage standalone PHP number to words converter library. Fully tested, open for extensions and new languages.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

currency money string number words to angle

13/04 2016

0.0.2

0.0.2.0

Multilanguage standalone PHP number to words converter library. Fully tested, open for extensions and new languages.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

currency money string number words to angle

09/12 2015

0.0.1

0.0.1.0

Multilanguage standalone PHP number to words converter library. Fully tested, open for extensions and new languages.

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

currency money string number words to angle