ntw

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 26, 2016 License: MIT Imports: 2 Imported by: 0

README

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

Documentation

Index

Examples

Constants

View Source
const Version = "0.1.0"

Version represents the package version

Variables

This section is empty.

Functions

func IntegerToAegean

func IntegerToAegean(input int) string

IntegerToAegean converts an integer to Aegean words

Example
fmt.Println(IntegerToAegean(42))
Output:

𐄓𐄈

func IntegerToDutch

func IntegerToDutch(input int) string

IntegerToDutch converts an integer to Dutch words

Example
fmt.Println(IntegerToDutch(42))
Output:

tweeenveertig

func IntegerToEnglish

func IntegerToEnglish(input int) string

IntegerToEnglish converts an integer to English words

Example
fmt.Println(IntegerToEnglish(42))
Output:

forty-two

func IntegerToFrench

func IntegerToFrench(input int) string

IntegerToFrench converts an integer to French words

Example
fmt.Println(IntegerToFrench(42))
Output:

quarante-deux

func IntegerToItalian

func IntegerToItalian(input int) string

IntegerToItalian converts an integer to Italian words

Example
fmt.Println(IntegerToItalian(42))
Output:

quarantadue

func IntegerToRoman

func IntegerToRoman(input int) string

IntegerToRoman converts an integer to Roman words

Example
fmt.Println(IntegerToRoman(42))
Output:

XLII

func IntegerToSwedish

func IntegerToSwedish(input int) string

IntegerToSwedish converts an integer to Swedish words

Example
fmt.Println(IntegerToSwedish(42))
Output:

fyrtio-två

func IntegerToUnicodeRoman

func IntegerToUnicodeRoman(input int) string

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL