Skip to content

A JavaScript utility to convert English integers into Nepali integers and useful strings with week and month names in the Nepali locale.

License

Notifications You must be signed in to change notification settings

danfebooks/nepalinumbers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nepalinumbers

A JavaScript utility to convert English integers into Nepali integers and useful strings with week and month names in the Nepali locale.



Bonus: Converts month and week numbers into Nepali Unicode names.

Why?

So that you don't need third-party API integration like Google Translation just to convert a few strings. Makes life easier and app lighter.

npm version

What it doesn't do

It doesn't convert dates or numbers from AD to BS or vice-versa;

How To

// Install the package:
`npm i -S @danfebooks/nepalinumbers;`

//Then follow the below examples,
import nepalinumbers from '@danfebooks/nepalinumbers';

// or, import only selected modules
import { week, month } from '@danfebooks/nepalinumbers';

const yearToConvert = 2019;
const convertedYear = nepalinumbers.numbers(yearToConvert);
// => २०१९

const numberToConvert = 35476865;
const convertedNumber = nepalinumbers.numbers(numberToConvert);
// => ३५४७६८६५

const monthToConvert = 12;
const convertedMonth = nepalinumbers.month(monthToConvert);
// => चैत

const weekToConvert = 2;
const convertedWeek = nepalinumbers.week(weekToConvert);
// => सोमबार

Pre-requisite

Babel or any ES6 Transpiler or Webpack within your App. The browser version of minified JS is coming soon!

Methods

Method Options Description
month 'all' or Integer Translate/Converts month number to Nepali Unicode
week 'all' or Integer Translate/Converts week number to Nepali Unicode
numbers n/a Transforms/Converts numbers to Nepali Unicode

Examples

const nepaliMonths = nepalinumbers.month('all');
// => ['बैशाख','जेठ','असार','साउन','भदौ','असोज','कार्तिक','मङि्सर','पुष','माघ','फागुन','चैत']
const nepaliWeeks = nepalinumbers.week('all');
// => ['आइतबार','सोमबार','मङ्गलबार','बुधबार','बिहिबार','शुक्रबार','शनिबार']