/number-to-words

convert number into words (english, french, italian, roman...)

Primary LanguageGoMIT LicenseMIT

number-to-words

GoDoc Build Status Coverage Status Go Report Card

Convert numbers to words.

Converti les nombres en lettres.

Supported languages / Langues supportées

  • American English / United States of America [en] 🇺🇸
  • Français / France [fr] 🇫🇷
  • Italiano / Italy [it] 🇮🇹
  • Swedish / Sweden [se] 🇸🇪
  • Dutch / Netherlands [nl] 🇳🇱
  • Roman numbers Ⅷ (with --unicode support)

CLI usage

$ number-to-words --lang=fr 42
quarante-deux

$ number-to-words --lang=it 42
quarantadue

$ number-to-words --lang=en 42
forty-two

$ number-to-words --lang=se 42
fyrtio-två

$ number-to-words --lang=nl 42
tweeenveertig

$ number-to-words --lang=roman 42
XLII

$ number-to-words --lang=roman --unicode 42
ⅩⅬⅡ

$ number-to-words --lang=aegean 42
𐄓𐄈

$ number-to-words 42
forty-two

$ number-to-words --lang=all 42
forty-two
quarante-deux
quarantadue
fyrtio-två
tweeenveertig
XLII
𐄓𐄈

$ number-to-words --lang=all 1
one
un
uno
en
één
I
𐄇

$ number-to-words --lang=all 1337
one thousand three hundred thirty-seven
mille trois cent trente-sept
uno mille trecento trentasette
en tusen tre hundra trettio-sju
éénduizend driehonderdzevenendertig
MCCCXXXVII
𐄢𐄛𐄒𐄍

$ number-to-words --lang=all 1234567890
one billion two hundred thirty-four million five hundred sixty-seven thousand eight hundred ninety
un milliard deux cent trente-quatre millions cinq cent soixante-sept mille huit cent quatre-vingt-dix
uno miliardo duecento trentaquattro milione cinquecento sessentasette mille ottocento novanta
en miljarder två hundra trettio-fyra miljoner fem hundra sextio-sju tusen åtta hundra nittio
één miljard tweehonderdvierendertig miljoen vijfhonderdzevenenzestigduizend achthonderdnegentig

$ number-to-words --lang=all 1000000000000
one quadrillion
un billiard
uno quadrillion
en biljoner
één biljoen

--help

$ number-to-words -h
NAME:
   number-to-words - number to number

USAGE:
   number-to-words [global options] command [command options] [arguments...]

VERSION:
   0.1.0

AUTHOR(S):
   Manfred Touron <https://github.com/moul/number-to-words>

COMMANDS:
GLOBAL OPTIONS:
   --lang value, -l value   Set language (default: "en") [$NTW_LANGUAGE]
   --help, -h               show help
   --version, -v            print the version

Unicode support

Roman support the --unicode option.

$ for i in {1..20}; do ./number-to-words -l roman -u $i; done












ⅩⅢ
ⅩⅣ
ⅩⅤ
ⅩⅥ
ⅩⅦ
ⅩⅧ
ⅩⅨ
ⅩⅩ

API usage

import "github.com/moul/number-to-words"

fmt.Println(ntw.IntegerToFrench(42))
// Outputs: quarante-deux

fmt.Println(ntw.IntegerToEnglish(42))
// Outputs: forty-two

fmt.Println(ntw.IntegerToItalian(42))
// Outputs: quarantadue

fmt.Println(ntw.IntegerToSwedish(42))
// Outputs: fyrtio-två

fmt.Println(ntw.IntegerToDutch(42))
// Outputs: tweeenveertig

fmt.Println(ntw.IntegerToRoman(42))
// Outputs: XLII

fmt.Println(ntw.IntegerToUnicodeRoman(42))
// Outputs: ⅩⅬⅡ

fmt.Println(ntw.IntegerToAegean(42))
// Outputs: 𐄓𐄈

Install

Using Golang

  1. install and configure go on your host
  2. get and build: go get github.com/moul/number-to-words/cmd/number-to-words
  3. profit: $GOPATH/bin/number-to-words 42

Using Homebrew

coming soon

Using Docker

  1. install and configure docker on your host
  2. profit: docker run --rm moul/number-to-words 42

License

MIT