https://github.com/axdraft/number-to-cyrillic
Convert number to words | English, Ukrainian, and Russian
https://github.com/axdraft/number-to-cyrillic
converts converts-number javascript number-to-cyrillic number-to-words
Last synced: about 1 year ago
JSON representation
Convert number to words | English, Ukrainian, and Russian
- Host: GitHub
- URL: https://github.com/axdraft/number-to-cyrillic
- Owner: axdraft
- License: mit
- Created: 2018-05-17T19:15:44.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2023-07-19T02:59:36.000Z (almost 3 years ago)
- Last Synced: 2025-01-02T02:08:21.977Z (over 1 year ago)
- Topics: converts, converts-number, javascript, number-to-cyrillic, number-to-words
- Language: JavaScript
- Homepage: https://npm.runkit.com/number-to-cyrillic
- Size: 164 KB
- Stars: 11
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://www.npmjs.com/package/number-to-cyrillic)
# Convert number to English, Russian or Ukrainian
[](https://badge.fury.io/js/number-to-cyrillic)
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](https://npm.runkit.com/number-to-cyrillic).
## 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:
```js
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:
| Option | Default Value | Description |
| :------------------------------: | :-----------: | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| capitalize | **`false`** | By 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. |
| customDecimalNameCasesForEnglish | **`false`** | By 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`. |
| customCurrencyPrefixForEnglish | **none** | By 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` |