|
| 1 | +# i18n-num-in-words |
| 2 | + |
| 3 | +## Convert Numbers to Words in Multiple Languages |
| 4 | + |
| 5 | +A small, zero-dependency JavaScript library for converting numbers to words in multiple languages. Optimized for both Node.js and browser environments. Star us on GitHub for more updates: |
| 6 | + |
| 7 | +[](https://github.com/ImBIOS/i18n-num-in-words) |
| 8 | + |
| 9 | +- [i18n-num-in-words](#i18n-num-in-words) |
| 10 | + - [Convert Numbers to Words in Multiple Languages](#convert-numbers-to-words-in-multiple-languages) |
| 11 | + - [Features](#features) |
| 12 | + - [Installation](#installation) |
| 13 | + - [npm](#npm) |
| 14 | + - [yarn](#yarn) |
| 15 | + - [pnpm](#pnpm) |
| 16 | + - [bun](#bun) |
| 17 | + - [Usage Example](#usage) |
| 18 | + - [Indonesian](#indonesian) |
| 19 | + - [English](#english) |
| 20 | + - [Arabic](#arabic) |
| 21 | + |
| 22 | +## Features |
| 23 | + |
| 24 | +- **Internationalized**: 95% of the world speaks languages other than English. We got you covered. |
| 25 | +- **Fully type safe**: Leverage TypeScript's type inference and static type safety. |
| 26 | +- **Small bundle size**: Zero dependencies make `i18n-num-in-words` lightweight. |
| 27 | +- **Test Coverage**: Nearly 100% test coverage guarantees reliability. |
| 28 | +- **Tree-shaking**: Import only the languages you use to optimize your bundle size. |
| 29 | + |
| 30 | +## Installation |
| 31 | + |
| 32 | +To start, choose the package manager you are most comfortable with: |
| 33 | + |
| 34 | +### npm |
| 35 | + |
| 36 | +```sh |
| 37 | +npm install i18n-num-in-words |
| 38 | +``` |
| 39 | + |
| 40 | +### yarn |
| 41 | + |
| 42 | +```sh |
| 43 | +yarn add i18n-num-in-words |
| 44 | +``` |
| 45 | + |
| 46 | +### pnpm |
| 47 | + |
| 48 | +```sh |
| 49 | +pnpm add i18n-num-in-words |
| 50 | +``` |
| 51 | + |
| 52 | +### bun |
| 53 | + |
| 54 | +```sh |
| 55 | +bun add i18n-num-in-words |
| 56 | +``` |
| 57 | + |
| 58 | +## Usage |
| 59 | + |
| 60 | +To convert numbers to words, first import the relevant function from the package. |
| 61 | + |
| 62 | +### Indonesian |
| 63 | + |
| 64 | +```ts |
| 65 | +import { indonesianNumInWords } from 'i18n-num-in-words'; |
| 66 | +console.log(indonesianNumInWords(1234567890)); |
| 67 | +``` |
| 68 | + |
| 69 | +Outputs: `'satu miliar dua ratus tiga puluh empat juta lima ratus enam puluh tujuh ribu delapan ratus sembilan puluh'` |
| 70 | + |
| 71 | +### English |
| 72 | + |
| 73 | +```ts |
| 74 | +import { englishNumInWords } from 'i18n-num-in-words'; |
| 75 | +console.log(englishNumInWords(1234567890)); |
| 76 | +``` |
| 77 | + |
| 78 | +Outputs: `'one billion two hundred thirty four million five hundred sixty seven thousand eight hundred ninety'` |
| 79 | + |
| 80 | +### Arabic |
| 81 | + |
| 82 | +```ts |
| 83 | +import { arabicNumInWords } from 'i18n-num-in-words'; |
| 84 | +console.log(arabicNumInWords(1234567890)); |
| 85 | +``` |
| 86 | + |
| 87 | +Outputs: `'مليار واحد ومائتان وأربعة وثلاثون مليون وخمسمائة وستة وسبعون ألف وثمانمائة وتسعون'` |
| 88 | + |
| 89 | +For details, check out our [full documentation](#). |
| 90 | + |
| 91 | +--- |
| 92 | + |
| 93 | +Feel free to star us on GitHub and contribute: [i18n-num-in-words GitHub Repo](https://github.com/ImBIOS/i18n-num-in-words) |
0 commit comments