Skip to content

digit grouping and conversion to formal spoken format for Farsi numbers

Notifications You must be signed in to change notification settings

sorooshrabet/iramount

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

number to persian text converter

This NodeJs library enables you to create formal Farsi spoken format for numbers that represent an amount in Rials (IRR).

install

using npm :

$ npm install iramount --save

Usage

const irAmount = require("iramount"); 
const amount = new irAmount(10239876); // constructor just accepts number 

Grouping Digits

To group digits by three, use

const withDigitGrouping = amount.digitGrouped(); // returns 10,239,876

params :

  • formatType | default = "R" | R = Rial and T = Toman
  • language | default = "EN" | EN = English and Fa = Farsi
  • groupDigitBy | default = 3
  • amount | constructor value

for Ex :

const withDigitGrouping = amount.digitGrouped("R", "Fa"); // returns ۱۰,۲۳۹,۸۷۶

or

const withDigitGrouping = amount.digitGrouped("T", "Fa", 2); // returns ۱,۰۲,۳۹,۸۷.۶

Convert To Text

To display Farsi spoken format in Rials (IRR), use

const rialFormat = amount.farsiFormatRial(); // returns ده میلیون و دویست و سی و نه هزار و هشتصد و هفتاد و شش ریال

To display Farsi spoken format in Tomans (Toman), use

const tomanFormat = amount.farsiFormatToman(); // returns یک میلیون و بیست و سه هزار و نهصد و هشتاد و هفت تومان
// showRial option to show Rials ...
const tomanFormat = amount.farsiFormatToman({ showRial: true }); // returns یک میلیون و بیست و سه هزار و نهصد و هشتاد و هفت تومان و شش ریال

special thanks :

About

digit grouping and conversion to formal spoken format for Farsi numbers

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%