This NPM library is made for converting numbers into their word representations in Dutch
Deze NPM library is gemaakt om cijfers om te zetten in hun Nederlandse uitgeschreven vorm
Based on the original num-to-words and took inspiration from the german package
- Convert integers and floats to words in Dutch
- Support for negative numbers and large numbers up to 16 characters, you can try for really large numbers but because of javascript limiations those won't be really accurate.
- Convert currency amounts into words, supporting the euro and the US dollar, other currencies can be added in the params of the function.
- Replace numbers in a string into words
npm install num-to-words
Using require syntax:
const numtowords = require('num-to-words-nl');
console.log(numtowords.int_to_words(123)); // Outputs: "honderddrieëntwintig"
console.log(numtowords.float_to_words(45.75, { capitals: true })); // Outputs: "Vijfenveertig komma Vijfenzeventig"
Using ES6 import syntax
import { int_to_words, float_to_words } from 'num-to-words-nl';
console.log(int_to_words(123, { capitals: true })); // Outputs: "Honderddrieëntwintig"
console.log(float_to_words(45.75, { capitals: true })); // Outputs: "Vijfenveertig komma Vijfenzeventig"
The function takes 2 parameters,
const numtowords = require('num-to-words-nl');
console.log(numtowords.num_to_currency(999.99, 'USD')); // Outputs: "negenhonderdnegenennegentig dollar en negenennegentig cent"
const numtowords = require('num-to-words-nl');
console.log(numtowords.replace_num_to_words("Ik heb 3 appels en 2 peren")); // Outputs: "Ik heb drie appels en twee peren"
const numtowords = require('num-to-words-nl')
console.log(numtowords.time_to_words("12:00")) // Outputs: "twaalf uur"
- USD (United States Dollar)
- EUR (Euro)
Converts an integer n
into its Dutch word representation.
n
: The integer to be converted.params
: Optional object with configuration parameters (capitals
for capitalizing the first letter,noWarnings
to suppress warnings).
Converts a float n
into its Dutch word representation.
n
: The float to be converted.params
: Optional object with configuration parameters (capitals
,noWarnings
).puntofkomma
: Optional string to specify the separator between integer and fractional parts. By default it iskomma
Converts a currency amount into its Dutch word representation.
amount
: The currency amount (float) to be converted.currency
: Optional string specifying the currency (default is 'EUR' for Euro).customCurrencyNames
: Optional object providing custom currency names.
Replaces all numeric substrings in text
with their Dutch word equivalents.
text
: The input text containing numbers to be replaced.
Writes out the time into its Dutch word representation
time
: The time inhh:mm
format. Example: 12:10 -> tien over twaalf.
npm run test
npm nl-numtowords-cli <number>
example:
npm exec nl-numtowords-cli 99 # negenennegentig
if globally installed (npm install num-to-word-nl -g
)
nl-numtowords-cli 99 # negenennegentig
You are welcome to submit a pull request for additional languages or errors I made in the current functions
This project is licensed under the MIT License - see the LICENSE file for details.