2.7.0 • Published 3 years ago

number-to-cyrillic v2.7.0

Weekly downloads
229
License
MIT
Repository
github
Last release
3 years ago

NPM

Convert number to English, Russian or Ukrainian

npm version

Converts number to words (UAH, RUB, USD, EUR and without currency). This library supports English, Ukrainian and Russian languages.

Install

npm install number-to-cyrillic

yarn add number-to-cyrillic

Demo

You can try this library here.

API

.convert(number[, options])

Converts an integer into an object witch contain value and the currency name. Optionally you can decide whether to display output with currency or not, to display a capital letter for the value by adding an object with some propertis. For example:

var numberToString = require('number-to-cyrillic');

numberToString.convert(21);
// {
//    convertedInteger: 'двадцять одна',
//    integerCurrency: 'гривня',
//    convertedFractional: 'нуль',
//    fractionalCurrency: 'копійок',
//    integer: 21,
//    fractional: 0,
//    shortName: 'грн.'
// }

numberToString.convert(34, {
  currency: 'usd'
});
// {
//    convertedInteger: 'тридцять чотири',
//    integerCurrency: 'долари США',
//    convertedFractional: 'нуль',
//    fractionalCurrency: 'центів',
//    integer: 34,
//    fractional: 0,
//    shortName: 'долара США'
// }

numberToString.convert(76.21, {
  capitalize: true
});
// {
//    convertedInteger: 'Сімдесят шість',
//    integerCurrency: 'гривень',
//    convertedFractional: 'двадцять одна',
//    fractionalCurrency: 'копійка',
//    integer: 76,
//    fractional: 21,
//    shortName: 'грн.'
// }

numberToString.convert(76.26, {
  language: 'en'
});
// {
//    convertedInteger: 'seventy-six',
//    integerCurrency: 'hryvnias',
//    convertedFractional: 'twenty-six',
//    fractionalCurrency: 'cents',
//    integer: 76,
//    fractional: 26,
//    shortName: 'UAH'
// }

See detailed description of all available options below:

OptionDefault ValueDescription
capitalizefalseBy setting a value for this option to true you might make the first letter in uppercase
currency'uah'By setting a value to this option to 'usd' or 'eur' or 'rub' or false you'll get the output for selected currency name or without currency.
language'ua'By setting a value to this option to 'en' or 'ru' you'll get the output for selected language.
customDecimalNameCasesForEnglishfalseBy setting a value for this option to true you will change default decimal name cases for UAH and RUB in English translation to kopek, kopeks.
customCurrencyPrefixForEnglishnoneBy setting a value for this option to a string you will change the default currency in English translation. E.g. without prefix: dollars, with - US dollars
2.7.0

3 years ago

2.6.6

3 years ago

2.6.5

4 years ago

2.6.4

4 years ago

2.6.3

4 years ago

2.6.2

5 years ago

2.6.1

5 years ago

2.6.0

5 years ago

2.5.1

5 years ago

2.5.0

5 years ago

2.4.5

5 years ago

2.4.4

5 years ago

2.4.3

5 years ago

2.4.2

5 years ago

2.4.1

5 years ago

2.4.0

5 years ago

2.3.2

5 years ago

2.3.1

6 years ago

2.3.0

6 years ago

2.2.1

6 years ago

2.2.0

6 years ago

2.1.0

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.4.1

6 years ago

1.4.0

6 years ago

1.3.3

6 years ago

1.3.2

6 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago