arabic-ntl

1.0.0 • Public • Published

Arabic NTL (Number to Letters)

Convert numbers to Arabic words with gender awareness support.

Installation

npm install arabic-ntl

Usage

ES6 Import

import { ntl, ArabicNTL } from 'arabic-ntl';

// Using singleton instance
const result = ntl.number(123).counted("كتاب").toWords();
// Output: "مئة و ثلاثة و عشرون كتاب"

// Using static method
const result2 = ArabicNTL.convert(456, "طالبة");
// Output: "أربع مئة و ستة و خمسون طالبة"

CommonJS

const { ntl, ArabicNTL } = require('arabic-ntl');

// Convert without counted item
const result = ntl.number(789).toWords();
// Output: "سبع مئة و تسعة و ثمانون"

Browser

<script src="node_modules/arabic-ntl/index.js"></script>
<script>
  const result = ntl.number(1000).counted("دينار").toWords();
  // Output: "ألف دينار"
</script>

API

Chained API

ntl.number(num).counted(item).toWords()
  • number(num): Set the number to convert
  • counted(item): Set the counted item (المعدود) - optional
  • toWords(): Convert to Arabic words

Static Method

ArabicNTL.convert(num, counted)
  • num: The number to convert
  • counted: The counted item (optional)

Create New Instance

const converter = new ArabicNTL();
converter.number(2500).toWords();
// Output: "ألفان و خمس مئة"

Features

  • ✅ Gender awareness (masculine/feminine)
  • ✅ Support for numbers up to trillions
  • ✅ Proper Arabic grammar rules
  • ✅ Zero configuration
  • ✅ Lightweight
  • ✅ No dependencies

Examples

// Masculine
ArabicNTL.convert(3, "كتاب")      // "ثلاثة كتاب"
ArabicNTL.convert(13, "قلم")      // "ثلاثة عشر قلم"
ArabicNTL.convert(2000, "ريال")   // "ألفان ريال"

// Feminine
ArabicNTL.convert(3, "طالبة")     // "ثلاث طالبة"
ArabicNTL.convert(13, "ورقة")     // "ثلاث عشرة ورقة"
ArabicNTL.convert(2000, "ليرة")   // "ألفان ليرة"

// Without counted item
ArabicNTL.convert(0)              // "صفر"
ArabicNTL.convert(100)            // "مئة"
ArabicNTL.convert(1000000)        // "مليون"

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i arabic-ntl

Weekly Downloads

1

Version

1.0.0

License

ISC

Unpacked Size

9.99 kB

Total Files

3

Last publish

Collaborators

  • 1ukaa