Giter Site home page Giter Site logo

axdraft / number-to-cyrillic Goto Github PK

View Code? Open in Web Editor NEW
11.0 1.0 2.0 168 KB

Convert number to words | English, Ukrainian, and Russian

Home Page: https://npm.runkit.com/number-to-cyrillic

License: MIT License

JavaScript 100.00%
converts javascript number-to-cyrillic number-to-words converts-number

number-to-cyrillic's Introduction

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:

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.