arqam 2.0.0 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +336 -298
- package/dist/SRI.txt +4 -4
- package/dist/arqamAR.d.mts +16 -8
- package/dist/arqamAR.mjs +2 -2
- package/dist/arqamEN.d.mts +8 -4
- package/dist/arqamExplain.d.mts +7 -4
- package/dist/arqamExplain.mjs +2 -2
- package/dist/arqamUnits.d.mts +8 -4
- package/dist/arqamUnits.mjs +1 -1
- package/dist/arqamWordsToNumbers.d.mts +12 -2
- package/dist/arqamWordsToNumbers.mjs +2 -2
- package/package.json +9 -5
package/README.md
CHANGED
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
<!-- README of the Arqam library and its Arabic engine (GitHub and npm): one README for both; ar/README.md
|
|
2
|
-
points here and the English engine keeps en/README.md. Every example below is checked by tests/readme.test.js.
|
|
3
|
-
The cards in images/readme/ are written from the engine by work/imgs (see docs/DEVELOPER.md). -->
|
|
4
1
|
<p align="center">
|
|
5
2
|
<img src="https://arqampro.com/images/ArqamLogo_2_128.png" width="96" height="96" alt="Arqam logo">
|
|
6
3
|
</p>
|
|
7
4
|
|
|
8
|
-
<h1 align="center">Arqam (أرقام) —
|
|
5
|
+
<h1 align="center">Arqam (أرقام) — Numbers in Words</h1>
|
|
9
6
|
|
|
10
|
-
<p align="center"
|
|
7
|
+
<p align="center">© 2020–2026 Mohsen Alyafei</p>
|
|
11
8
|
|
|
12
9
|
<p align="center">
|
|
13
|
-
Currency amounts, numbers (cardinals and ordinals), dates and times in correct words
|
|
14
|
-
Arabic
|
|
15
|
-
|
|
10
|
+
Currency amounts, numbers (cardinals and ordinals), dates, and times in grammatically correct words — in both <strong>Arabic</strong> and <strong>English</strong>.<br><br>
|
|
11
|
+
The Arabic output includes full <em>i'rab</em> (إعراب) and <em>tashkeel</em> (تشكيل), and Arabic words can be parsed back into numbers.<br><br>
|
|
12
|
+
<em>Tafqeet</em> (تفقيط, also spelled <em>tafqit</em> or <em>tafgeet</em>) in JavaScript: the successor to <code>tafqit</code> and <code>nArabicWords</code>.<br><br>
|
|
13
|
+
Pure JavaScript · Zero dependencies · No network · MIT Licence
|
|
16
14
|
</p>
|
|
17
15
|
|
|
16
|
+
|
|
18
17
|
<p align="center">
|
|
19
18
|
<a href="https://arqampro.com"><b>Try it online</b></a> ·
|
|
20
19
|
<a href="https://arqampro.com/docs/manual.html"><b>Manual</b></a> ·
|
|
21
20
|
<a href="https://arqampro.com/docs/playground.html"><b>Playground</b></a> ·
|
|
22
|
-
<a href="https://arqampro.com/download/"><b>Download</b></a>
|
|
21
|
+
<a href="https://arqampro.com/download/"><b>Download</b></a> ·
|
|
22
|
+
<a href="https://arqampro.com/docs/golden.html"><b>Golden Book</b></a> ·
|
|
23
|
+
<a href="https://arqampro.com/tafqeet/"><b>Currencies</b></a>
|
|
23
24
|
</p>
|
|
24
25
|
|
|
25
26
|
<p align="center">
|
|
@@ -34,21 +35,20 @@
|
|
|
34
35
|
## Arabic numbers in words, written the way a grammarian would
|
|
35
36
|
|
|
36
37
|
Cheques, invoices, contracts and certificates need amounts in words that are *right*, not almost right.
|
|
37
|
-
Arqam writes them with the correct gender, number and case every time, and is checked against
|
|
38
|
-
285,624 reference entries. The successor of tafqit and nArabicWords.
|
|
38
|
+
Arqam writes them with the correct gender, number and case every time, and is checked against the Golden Book's **350,100 entries** (314,028 number forms and 36,072 currency-amount forms). The successor of tafqit and nArabicWords.
|
|
39
39
|
|
|
40
40
|
| Why Arqam | What you get |
|
|
41
41
|
|---|---|
|
|
42
|
-
|
|
|
43
|
-
|
|
|
44
|
-
|
|
|
45
|
-
|
|
|
46
|
-
|
|
|
47
|
-
|
|
|
48
|
-
|
|
|
49
|
-
|
|
|
50
|
-
|
|
|
51
|
-
|
|
|
42
|
+
| **Correct Arabic, every time** | Gender agreement for 3–10, the dual, all three cases of إعراب (rafʿ, naṣb and jarr) and tashkeel at six levels, from none to full, checked against the Golden Book's 350,100 entries (314,028 number forms and 36,072 currency-amount forms) |
|
|
43
|
+
| **Ready for cheques and invoices** | 188 currencies with their subunits, «فقط … لا غير», the legal wording, and the same amount in English |
|
|
44
|
+
| **No size limit** | Whole numbers of any length and decimals with as many places as you need; the benchmark writes numbers of up to 1,000,000 digits |
|
|
45
|
+
| **More than amounts** | Ordinals up to 999,999, Hijri and Gregorian dates, times and fractions |
|
|
46
|
+
| **Words back to numbers** | `arqam/words` reads Arabic amounts back into figures, to check a document, including local dialects: «ألفين وخمسمية» as 2500 |
|
|
47
|
+
| **Explains its own grammar** | `arqam/explain` gives each word's case (الإعراب), the reason and the rule: for schools, students and proofreaders |
|
|
48
|
+
| **Units of measure** | `arqam/units`: 304 units, by their international or Arabic names |
|
|
49
|
+
| **Arabic and English** | `arqam/en` writes the same amount in UK or US English, for bilingual documents |
|
|
50
|
+
| **The Golden Book** | A free reference of Arabic number and amount words: 7,934 numbers in every gender and case, with no marks, the tanween alif or full tashkeel, with and without the legal form, as JSON: 350,100 entries (314,028 number forms and 36,072 currency-amount forms). Use it to test any tafqeet engine, in any programming language: [golden/](https://github.com/MohsenAlyafei/arqam/blob/master/golden/) · [see it online](https://arqampro.com/docs/golden.html) |
|
|
51
|
+
| **Light and private** | Pure JavaScript, no dependencies, nothing sent over the network, TypeScript types, MIT licence |
|
|
52
52
|
|
|
53
53
|
**Try it in ten seconds:**
|
|
54
54
|
|
|
@@ -66,13 +66,16 @@ Or use it online, free and with nothing to install, at **[arqampro.com](https://
|
|
|
66
66
|
|
|
67
67
|
```js
|
|
68
68
|
import arqam from "arqam";
|
|
69
|
-
import "arqam/en";
|
|
69
|
+
import "arqam/en"; // English: adds itself to arqam, so it needs no name
|
|
70
70
|
|
|
71
|
-
arqam("1250.50", "ar-
|
|
72
|
-
|
|
73
|
-
arqam(1250
|
|
71
|
+
arqam("1250.50", "ar-SA", {style: "currency", currency: "SAR"});
|
|
72
|
+
// ألف ومائتان وخمسون ريالًا سعوديًا، وخمسون هللةً
|
|
73
|
+
arqam("1250.50", "en-US", {style: "currency", currency: "SAR"});
|
|
74
|
+
// One Thousand Two Hundred Fifty Saudi Riyals and Fifty Halalahs
|
|
75
|
+
arqam(1250); // ألف ومائتان وخمسون
|
|
74
76
|
// a BigInt, for whole numbers beyond a JavaScript number's exact range:
|
|
75
|
-
arqam(9007199254740993n, "SAR");
|
|
77
|
+
arqam(9007199254740993n, "SAR");
|
|
78
|
+
// تسعة كوادرليونات وسبعة تريليونات ومائة وتسعة وتسعون مليارًا ومائتان وأربعة وخمسون مليونًا وسبعمائة وأربعون ألفًا وتسعمائة وثلاثة وتسعون ريالًا سعوديًا
|
|
76
79
|
```
|
|
77
80
|
|
|
78
81
|
<p align="left"><img src="https://arqampro.com/images/readme/example-big.png" width="690" alt="Arqam: arqam(9007199254740993n, "SAR"), in coloured words"></p>
|
|
@@ -83,7 +86,7 @@ same as `arqam.toWords`, and a currency code in place of the locale makes the nu
|
|
|
83
86
|
|
|
84
87
|
```js
|
|
85
88
|
arqam("1250.50", "DZD"); // ألف ومائتان وخمسون دينارًا جزائريًا، وخمسون سنتيمًا
|
|
86
|
-
arqam("2", "DZD");
|
|
89
|
+
arqam("2", "DZD"); // ديناران جزائريان
|
|
87
90
|
arqam("2", "DZD", {prefix: "فقط", suffix: "لا غير"}); // فقط ديناران جزائريان اثنان لا غير
|
|
88
91
|
```
|
|
89
92
|
|
|
@@ -95,118 +98,54 @@ is said twice; `emphasisOneTwo: "on"` writes it always.
|
|
|
95
98
|
The locale chooses the language, and
|
|
96
99
|
Intl's option names, defaults and methods are kept; Arqam's own options sit beside them.
|
|
97
100
|
|
|
98
|
-
>
|
|
99
|
-
>
|
|
100
|
-
> `
|
|
101
|
+
> [!NOTE]
|
|
102
|
+
> **Arqam 2 is the latest library.** Version `1.1.2` on npm was my earlier 2020 release (`arqam@1`); if you use it, stay
|
|
103
|
+
> on `arqam@1`. Version 2 (`arqam`) brings the full `arqamAR` grammar engine, `arqam/words` and `arqam/explain`.
|
|
101
104
|
|
|
102
105
|
<p align="center">
|
|
103
106
|
<a href="https://arqampro.com"><img src="https://arqampro.com/images/page-preview.png" width="820" alt="The Arqam page at arqampro.com: a number typed in, its words, and the options"></a><br>
|
|
104
107
|
<sub>The Arqam page at <a href="https://arqampro.com">arqampro.com</a> uses this library. Everything it does, your code can do.</sub>
|
|
105
108
|
</p>
|
|
106
109
|
|
|
107
|
-
## Web API: tafqeet from any program
|
|
108
|
-
|
|
109
|
-
Arqam also answers over the web at **`https://api.arqampro.com`**, free and with no key, for programs that do not run
|
|
110
|
-
JavaScript: Excel, Python, PHP, C# and no-code tools. (In JavaScript, use the library itself: it needs no internet.)
|
|
111
|
-
|
|
112
|
-
```text
|
|
113
|
-
https://api.arqampro.com/v1/words?n=1250.50¤cy=SAR
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
```json
|
|
117
|
-
{ "input": "1250.50", "words": "ألف ومائتان وخمسون ريالًا سعوديًا، وخمسون هللةً", "version": "1.90" }
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
| Call | Gives |
|
|
121
|
-
|---|---|
|
|
122
|
-
| `/v1/words?n=…` | a number or amount in Arabic words |
|
|
123
|
-
| `/v1/bilingual?n=…¤cy=…` | Arabic and English at once, in the cheque form |
|
|
124
|
-
| `/v1/english?n=…` | a number or amount in English words |
|
|
125
|
-
| `/v1/date?d=23/11/2026` | a date in words (`calendar=g`, `h` or `b`) |
|
|
126
|
-
| `/v1/time?t=15:45` | a time in words |
|
|
127
|
-
| `/v1/value?text=…` | Arabic words back to their number |
|
|
128
|
-
| `/v1/explain?n=…` | the إعراب of each word |
|
|
129
|
-
|
|
130
|
-
The options are the library's own (`currency`, `tashkeel`, `ierab`, `legal`, `wordOrder` …); `format=text` gives the
|
|
131
|
-
words alone. Excel for Windows, with the amount in A2:
|
|
132
|
-
|
|
133
|
-
```text
|
|
134
|
-
=WEBSERVICE("https://api.arqampro.com/v1/words?n="&A2&"¤cy=SAR&format=text")
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
```python
|
|
138
|
-
import requests
|
|
139
|
-
r = requests.get("https://api.arqampro.com/v1/words", params={"n": "1250.50", "currency": "SAR"})
|
|
140
|
-
print(r.json()["words"])
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
Every call, its options and examples for PHP, C# and curl: [the API page](https://arqampro.com/en/tafqeet/api/).
|
|
144
|
-
|
|
145
110
|
## Contents
|
|
146
111
|
|
|
147
|
-
|
|
|
112
|
+
| **Get started** | **The Arabic engine** | **Languages and more** |
|
|
148
113
|
|:---|:---|:---|
|
|
149
|
-
| [Why Arqam](#why-arqam)<br>[Why not ask an AI model?](#why-not-ask-an-ai-model-to-do-the-job)<br>[
|
|
114
|
+
| [Why Arqam](#why-arqam)<br>[Why not ask an AI model?](#why-not-ask-an-ai-model-to-do-the-job)<br>[Install](#install)<br>[Quick start](#quick-start)<br>[Recipes](#recipes)<br>[Web API](#web-api-tafqeet-from-any-program) | [The engine (arqamAR)](#the-arabic-engine-arqamar)<br>[Specifications](#specifications)<br>[The calls](#the-calls)<br>[Options](#options)<br>[The Intl-style formatter](#the-intl-style-formatter)<br>[Units of measure](#units-of-measure)<br>[Regions and time zones](#regions-and-time-zones)<br>[Approximate quantities](#approximate-quantities)<br>[Words back to numbers](#words-back-to-numbers)<br>[Explain the grammar](#explain-the-grammar)<br>[Eastern and Western digits](#arabic-eastern-and-arabic-western-numbers) | [Languages](#languages)<br>[Two languages at once](#two-languages-at-once)<br>[Documents: cheques, invoices …](#documents-cheques-invoices-receipts-contracts)<br>[Adding a language](#adding-a-language)<br>[TypeScript, browsers and size](#typescript-browsers-node-and-size)<br>[Documentation and online tools](#documentation-and-online-tools)<br>[This repository](#this-repository)<br>[Licence and author](#licence-and-author) |
|
|
150
115
|
|
|
151
116
|
<!-- gen:why -->
|
|
152
117
|
## Why Arqam
|
|
153
118
|
|
|
154
|
-
Many
|
|
119
|
+
Many tools and libraries convert numbers into Arabic words, yet most get the grammar wrong; from the gender polarity of numbers (التذكير والتأنيث) for three (3) through ten (10) to the dual form (المثنى), case endings (الإعراب), and scale words.
|
|
155
120
|
|
|
156
|
-
Arqam
|
|
121
|
+
Arqam (أرقام, meaning "numbers") was built to ensure that every amount on a cheque, invoice, or contract is written in accurate, formal Arabic (التفقيط), completely free for everyone.
|
|
157
122
|
|
|
158
|
-
|
|
123
|
+
### Key technical advantages
|
|
124
|
+
|
|
125
|
+
- **Classical Arabic grammar (naḥw and ṣarf)**
|
|
126
|
+
- **Gender and the counted noun:** 1 and 2 agree with the noun, 3 to 10 take the opposite gender, and the compounds 11 to 19 and 21 to 99 follow their own rules.
|
|
127
|
+
- **Case (إعراب):** nominative, accusative and genitive. The dual drops its ن in iḍāfa (ألفا ريال, not ألفان ريال), and the تمييز after 11 to 99 is accusative.
|
|
128
|
+
- **Spelling and marks:** more than 60 options, among them tashkeel from none to full, مائة or مئة, the Arabic (مليار), short (بليون) and long scales, and the cheque form «فقط … لا غير».
|
|
129
|
+
- **188 currencies, exact amounts:** each with its unit and sub-unit, decimal places, gender and plurals. Amounts are read as text or BigInt, so there is no floating-point error, and there is no limit on the size of a number.
|
|
130
|
+
- **More than amounts:** ordinals, approximate quantities (قرابة، ما يزيد على، أقل من، بضعة، نيّف), Hijri and Gregorian dates, times and fractions. Arabic words read back into digits (`arqam/words`), and the إعراب of every word (`arqam/explain`).
|
|
131
|
+
- **No dependencies, runs anywhere:** ES modules for the browser (also straight from jsDelivr), Node, Deno and bundlers; Arabic built in, English as `arqam/en`.
|
|
132
|
+
- **Checked against the Golden Book:** 350,100 entries (314,028 number forms and 36,072 currency-amount forms).
|
|
159
133
|
|
|
160
|
-
| What you need | Arqam |
|
|
161
|
-
|---|---|
|
|
162
|
-
| Numbers and amounts in words (تفقيط) | 188 currencies, 304 units of measure, ordinals, percentages, Gregorian and Hijri dates, times and fractions |
|
|
163
|
-
| No limit on the size of the number | any number of whole and decimal digits: only the computer's memory sets the limit. Words back to numbers reads whole numbers of up to thirty-six (36) digits |
|
|
164
|
-
| إعراب: الرفع والنصب والجر | option `ierab` |
|
|
165
|
-
| Tashkeel (التشكيل) | six (6) modes, from none to full: option `tashkeel` |
|
|
166
|
-
| «اشرح»: the grammar of every word | every word with its إعراب, the reason and the rule: `arqam/explain` |
|
|
167
|
-
| Words back to numbers | `arqam/words`: dialect words too, and `verify()` checks words against their figure |
|
|
168
|
-
| Legal form for cheques and contracts | option `legal` |
|
|
169
|
-
| The words in parts, for separate fields | `formatToParts()`: the number, the decimals, the currency and the sub-unit, each labelled |
|
|
170
|
-
| Ranges in words («من … إلى …») | `formatRange()` for numbers, currencies, counted nouns, units, percentages, ordinals, fractions, times, Gregorian and Hijri dates |
|
|
171
|
-
| Tests | eighty-one (81) engine Test Cases; seven hundred and sixty-six (766) words-to-numbers cases; 53,859 «اشرح» calls (250,564 words) checked word by word, with no mismatch; more than 160,000 random checks in eleven (11) parts; thirty-eight (38) page-test files in a real browser |
|
|
172
|
-
|
|
173
|
-
The figures are written by `tools/build_why.js` from the library and from the latest passing test run.
|
|
174
|
-
|
|
175
|
-
### What makes Arqam different from other libraries
|
|
176
|
-
|
|
177
|
-
- **A rule-based Arabic grammar engine.** Arqam works from the rules of Arabic grammar rather than fixed templates. It handles duals, iḍāfa, the three cases (nominative, accusative, genitive) and gender agreement. It can explain every word's grammar (إعراب الكلمات), and it offers 6 levels of tashkeel: none, alif, fatha, tanween, endings and full.
|
|
178
|
-
- **Numbers of any length, and wide coverage.** There is no upper limit on the number of digits. Arqam covers 188 currencies, 304 units of measure, Hijri and Gregorian dates, times, fractions and ordinals. It has a legal mode for cheques that leaves no room for ambiguity, and it reads written Arabic, colloquial phrasing included, back into digits.
|
|
179
|
-
- **Arabic and English from one call.** With the English add-on, `toBilingual()` gives matching Arabic and English words for the same amount, for bilingual invoices, contracts and financial documents.
|
|
180
|
-
- **One design, a familiar API.** Units of measure use the same `registerCurrency()` machinery as currencies (`secondAs`: iḍāfa or qualifier), and `arqamAR.NumberFormat` follows `Intl.NumberFormat` (`style: "currency"`, `style: "unit"`). The library stays compact and familiar to JavaScript and TypeScript developers.
|
|
181
|
-
- **Private and open.** Everything runs on the user's device, with no dependencies, so nothing typed leaves it. The engine is checked against the Golden Book's 285,624 reference entries. Arqam is Open Source under the MIT licence.
|
|
182
134
|
<!-- /gen:why -->
|
|
183
135
|
|
|
184
136
|
## Why not ask an AI model to do the job?
|
|
185
137
|
|
|
186
|
-
AI models are useful for many things, but
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
- **
|
|
190
|
-
|
|
191
|
-
- **
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
a batch of thousands of amounts without waiting.
|
|
198
|
-
- **Your data leaves your system.** The amount, and often the payee or the contract around it, is sent to a third
|
|
199
|
-
party, which banks, auditors and legal teams may not allow.
|
|
200
|
-
- **It costs and it can stop.** Requests are paid for or limited, need an account and a key, and depend on a service
|
|
201
|
-
that can change or stop.
|
|
202
|
-
|
|
203
|
-
Arqam is built for exactly this job:
|
|
204
|
-
|
|
205
|
-
- It runs locally and offline, in tens of microseconds, on deterministic classical grammar rules: the same input gives
|
|
206
|
-
the same words every time, on every machine.
|
|
207
|
-
- Every result is checked against the 285,624 entries of the golden book.
|
|
208
|
-
- It explains its own grammar, word by word, with `arqam/explain`.
|
|
209
|
-
- Nothing is sent anywhere, and it costs nothing.
|
|
138
|
+
AI models are useful for many things, but an amount in words for a cheque or a contract is not one of them. Asked for
|
|
139
|
+
"432,215.750 KWD in the accusative, with full tashkeel", a model:
|
|
140
|
+
|
|
141
|
+
- **is not always right**: a wrong gender, case or tanween looks just as fluent as the right one;
|
|
142
|
+
- **is not always the same**: the words can change from one request, model or version to the next;
|
|
143
|
+
- **is hard to check**: it does not show the rule behind each word;
|
|
144
|
+
- **is slow and online**: each answer is a network call that takes seconds;
|
|
145
|
+
- **sends your data away**: the amount, and often the payee, goes to a third party.
|
|
146
|
+
|
|
147
|
+
Arqam runs locally, in microseconds, on fixed grammar rules: the same input gives the same words on every machine,
|
|
148
|
+
and `arqam/explain` shows the rule behind each word.
|
|
210
149
|
|
|
211
150
|
```js
|
|
212
151
|
arqam.toWords("432215.750", "KWD", {ierab: "nasb", tashkeel: "full"});
|
|
@@ -215,78 +154,6 @@ arqam.toWords("432215.750", "KWD", {ierab: "nasb", tashkeel: "full"});
|
|
|
215
154
|
|
|
216
155
|
<p align="left"><img src="https://arqampro.com/images/readme/example-kwd.png" width="690" alt="Arqam: 432215.750 Kuwaiti dinars with full tashkeel, in coloured words"></p>
|
|
217
156
|
|
|
218
|
-
## Features at a glance
|
|
219
|
-
|
|
220
|
-
Everything below is in the library today, with no dependencies and no network.
|
|
221
|
-
|
|
222
|
-
**1. Arabic grammar engine**
|
|
223
|
-
|
|
224
|
-
- **Gender agreement (المذكر والمؤنث):** 1 and 2 agree with the counted noun (واحد / واحدة، اثنان / اثنتان); 3–10 take
|
|
225
|
-
the opposite gender; 11 and 12 agree in both parts (أحد عشر، إحدى عشرة); in 13–19 the first part takes the opposite
|
|
226
|
-
gender and عشر / عشرة agrees; the tens do not change and their units follow the rules of 1–9.
|
|
227
|
-
- **Case (الإعراب):** nominative, accusative and genitive (`ierab`) for cardinals, ordinals, duals and sound plurals
|
|
228
|
-
(مائتان / مائتين، ألفان / ألفين، عشرون / عشرين), and for amounts, dates, times and fractions.
|
|
229
|
-
- **Iḍāfa and the dual:** the ن of the dual drops before what it is added to (مائتا ألف، ألفا ريال).
|
|
230
|
-
- **Every form of the counted noun:** singular (1), dual (2), plural (3–10), accusative singular (11–99: ريالًا، دينارًا،
|
|
231
|
-
هللةً) and genitive singular (100 and up), for every currency, unit and noun of your own.
|
|
232
|
-
- **Tashkeel:** six modes, from none, through tanween only (ريالًا), to full tashkeel (`tashkeel`), always in Unicode's
|
|
233
|
-
standard order.
|
|
234
|
-
- **Word order:** largest part first (the default) or smallest first: خمسون ومائتان وألف (`wordOrder`).
|
|
235
|
-
- **Cheques and contracts:** the legal form (`legal`), «فقط … لا غير» (`prefix`, `suffix`) and the figure in brackets.
|
|
236
|
-
|
|
237
|
-
**2. Regional forms**
|
|
238
|
-
|
|
239
|
-
- مائة or مئة (`miah`), written together or apart: ثلاثمائة / ثلاث مائة (`miahSplit`).
|
|
240
|
-
- The Arabic scale (مليار), the short scale (بليون) and the long, European scale (`scale`).
|
|
241
|
-
- The twenty-two (22) Arab League locales, each with its currency, month names (يناير، كانون الثاني، جانفي …), time
|
|
242
|
-
zone and numerals (`locale`).
|
|
243
|
-
- The fraction in words (وخمسون هللة), in figures, as a fraction (و5/10 ريال), with «فاصلة», or digit by digit
|
|
244
|
-
(`decFormat`).
|
|
245
|
-
- Arabic-Eastern (٠١٢٣٤٥٦٧٨٩) and Arabic-Western (0123456789) numbers, in and out.
|
|
246
|
-
|
|
247
|
-
**3. Money and precision**
|
|
248
|
-
|
|
249
|
-
- **Exact input:** text, JavaScript numbers and BigInt, with no floating-point error (19.99 stays 19.99), and no limit
|
|
250
|
-
on the size of a number or on its decimals: decillion (10³³) and far beyond.
|
|
251
|
-
- **188 currencies** (ISO 4217, the withdrawn ones still found in old documents, and 13 cryptocurrencies), each with
|
|
252
|
-
the gender of its unit and sub-unit, every noun form and its number of decimals: two for QAR (ريال / درهم), SAR
|
|
253
|
-
(ريال / هللة), AED (درهم / فلس), EGP (جنيه / قرش), USD and EUR; three for KWD, BHD, OMR, JOD and TND; none for JPY and
|
|
254
|
-
KRW.
|
|
255
|
-
- **Your own currency or noun:** `registerCurrency` with its names, gender and decimals; and 304 units of measure
|
|
256
|
-
ready to use (`arqam/units`).
|
|
257
|
-
- **No silent rounding:** digits beyond the currency's places are cut by default; `rounding: "on"` rounds and carries
|
|
258
|
-
into the whole number (9.999 → 10.00).
|
|
259
|
-
- A sub-unit of zero is left out (مائة ريال), and the figure in brackets can still show it (100.00 QAR).
|
|
260
|
-
- Negative numbers («سالب …»), and `strict` to report input that is not a number instead of returning a default.
|
|
261
|
-
|
|
262
|
-
**4. Beyond money**
|
|
263
|
-
|
|
264
|
-
- Cardinal numbers, masculine or feminine; ordinals from 1 to 999,999 (الأول / الأولى، الحادي عشر / الحادية عشرة).
|
|
265
|
-
- Percentages (بالمائة / بالمئة, decimals included: ثلاثة فاصلة خمسة بالمائة) and approximate quantities (قرابة، بضعة،
|
|
266
|
-
نيّف).
|
|
267
|
-
- Fractions by name (نصف، ثلث، ثلاثة وثلاثة أرباع), as parts, or mixed (`toFraction`).
|
|
268
|
-
- Gregorian and Hijri (Umm al-Qura) dates, times, durations and time zones (`toDate`, `toTime`, `toDateTime`); a Hijri
|
|
269
|
-
date is recognised by «هـ» or by its month name.
|
|
270
|
-
- **Words back to numbers** (`arqam/words`): any tashkeel, missing hamzas (احد / أحد), dialect words (تلاتة، خمستاشر،
|
|
271
|
-
ميتين), amounts, dates, times and durations; `verify()` checks words against their figure, for cheques, invoices and
|
|
272
|
-
OCR.
|
|
273
|
-
- **«اشرح»** (`arqam/explain`): the إعراب of every word, with its reason and rule.
|
|
274
|
-
- An `Intl`-style formatter (`NumberFormat`: `format`, `formatToParts`, `formatRange`).
|
|
275
|
-
- **Bilingual amounts and documents:** the amount in Arabic and English in one call (`toBilingual`), and the wording
|
|
276
|
-
of a cheque, invoice, receipt or contract clause in Arabic, English or both (`toClause`).
|
|
277
|
-
|
|
278
|
-
**5. For developers**
|
|
279
|
-
|
|
280
|
-
- No dependencies and no network; ES modules and plain scripts; the units, the reader, «اشرح» and English are
|
|
281
|
-
separate modules, loaded only if you import them.
|
|
282
|
-
- **One library, many languages:** each language is its own engine (`arqamAR`, `arqamEN` …) reached through `arqam`;
|
|
283
|
-
a new language is a new module.
|
|
284
|
-
- TypeScript declarations for every method, option and value.
|
|
285
|
-
- A misspelt option or value is an error that suggests the right one ("did you mean").
|
|
286
|
-
- A web playground and a full manual, with questions and answers, at [arqampro.com](https://arqampro.com).
|
|
287
|
-
- Tests: the engine's Test Cases, a sweep of 49,424 calls checked word for word, golden sets, round trips through the
|
|
288
|
-
reader, and random tests.
|
|
289
|
-
|
|
290
157
|
## Install
|
|
291
158
|
|
|
292
159
|
```
|
|
@@ -304,6 +171,50 @@ The modules are minified, each under a banner with its version and licence; the
|
|
|
304
171
|
|
|
305
172
|
`dist/SRI.txt` has an integrity hash for every module.
|
|
306
173
|
|
|
174
|
+
**In a web page, from a CDN.** jsDelivr serves the latest version of the npm package, so fixes and new features
|
|
175
|
+
arrive by themselves; every new version of Arqam stays backward compatible. To keep one exact version, write
|
|
176
|
+
`arqam@2.0.2` in the address.
|
|
177
|
+
|
|
178
|
+
```html
|
|
179
|
+
<script type="module">
|
|
180
|
+
import arqam from "https://cdn.jsdelivr.net/npm/arqam/dist/arqamAR.mjs";
|
|
181
|
+
import "https://cdn.jsdelivr.net/npm/arqam/dist/arqamEN.mjs"; // English, if wanted
|
|
182
|
+
document.body.textContent = arqam("1250.50", "SAR");
|
|
183
|
+
</script>
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
For every part, an import map gives the page the same names as npm (`"arqam"`, `"arqam/en"`, `"arqam/words"`,
|
|
187
|
+
`"arqam/explain"`, `"arqam/units"`); the parts import `./arqamAR.mjs` beside them, so all share one library:
|
|
188
|
+
|
|
189
|
+
```html
|
|
190
|
+
<script type="importmap">
|
|
191
|
+
{"imports": {
|
|
192
|
+
"arqam": "https://cdn.jsdelivr.net/npm/arqam/dist/arqamAR.mjs",
|
|
193
|
+
"arqam/en": "https://cdn.jsdelivr.net/npm/arqam/dist/arqamEN.mjs",
|
|
194
|
+
"arqam/words": "https://cdn.jsdelivr.net/npm/arqam/dist/arqamWordsToNumbers.mjs",
|
|
195
|
+
"arqam/explain": "https://cdn.jsdelivr.net/npm/arqam/dist/arqamExplain.mjs",
|
|
196
|
+
"arqam/units": "https://cdn.jsdelivr.net/npm/arqam/dist/arqamUnits.mjs"
|
|
197
|
+
}}
|
|
198
|
+
</script>
|
|
199
|
+
<script type="module">
|
|
200
|
+
import arqam from "arqam";
|
|
201
|
+
import "arqam/en"; // English: adds itself to arqam (nothing to name)
|
|
202
|
+
import wordsToNumbers from "arqam/words"; // words back to numbers
|
|
203
|
+
import arqamExplain from "arqam/explain"; // the grammar of each word
|
|
204
|
+
import "arqam/units"; // units of measure: adds itself to arqam.NumberFormat
|
|
205
|
+
|
|
206
|
+
arqam("1250.50", "SAR"); // in Arabic words
|
|
207
|
+
arqam("1250.50", "en-GB", {currency: "SAR"}); // in English words
|
|
208
|
+
wordsToNumbers("ألفان وخمسمائة ريال"); // the number back
|
|
209
|
+
arqamExplain("1250.50", {currency: "SAR"}).words; // each word, with its grammar
|
|
210
|
+
new arqam.NumberFormat("ar", {style: "unit", unit: "kilometer"}).format(12.5);
|
|
211
|
+
</script>
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
Take only the lines you need. `arqam/en` and `arqam/units` have no `from`: importing them adds English and the units
|
|
215
|
+
to `arqam`, so there is nothing to name. To check the files, give the exact version (`arqam@2.0.2`) and add an
|
|
216
|
+
`"integrity"` entry to the import map with the hashes in `dist/SRI.txt`.
|
|
217
|
+
|
|
307
218
|
**Without npm**, take the files from [`dist/`](https://github.com/MohsenAlyafei/arqam/blob/master/dist/) in this repository or from the [download page](https://arqampro.com/download/),
|
|
308
219
|
or load the plain scripts in [`src/`](https://github.com/MohsenAlyafei/arqam/blob/master/src/) with a `<script>` tag:
|
|
309
220
|
|
|
@@ -319,7 +230,7 @@ or load the plain scripts in [`src/`](https://github.com/MohsenAlyafei/arqam/blo
|
|
|
319
230
|
|
|
320
231
|
```js
|
|
321
232
|
import arqam from "arqam";
|
|
322
|
-
import "arqam/en";
|
|
233
|
+
import "arqam/en"; // English: adds itself to arqam, so it needs no name
|
|
323
234
|
|
|
324
235
|
arqam("1250.50", "ar-SA", {style: "currency", tashkeel: "full", prefix: "فقط", suffix: "لا غير", brackets: "end", numberingSystem: "latn"});
|
|
325
236
|
// فَقَطْ أَلْفٌ وَمِائَتَانِ وَخَمْسُونَ رِيَالًا سُعُودِيًّا، وَخَمْسُونَ هَلَلَةً لَا غَيْرْ (1,250.50 SAR)
|
|
@@ -329,10 +240,10 @@ arqam.toDate("18/11/2026", {calendar: "both", tashkeel: "full"});
|
|
|
329
240
|
// الثَّامِنَ عَشَرَ مِنْ شَهْرِ نُوفَمْبِرَ لِعَامِ أَلْفَيْنِ وَسِتَّةٍ وَعِشْرِينَ لِلْمِيلَادِ، الْمُوَافِقُ الثَّامِنَ مِنْ شَهْرِ جُمَادَى الْآخِرَةِ لِعَامِ أَلْفٍ وَأَرْبَعِمِائَةٍ وَثَمَانِيَةٍ وَأَرْبَعِينَ لِلْهِجْرَةِ
|
|
330
241
|
arqam("1250.50", "en-GB", {style: "currency", currency: "QAR", only: "end", brackets: "end"});
|
|
331
242
|
// One Thousand Two Hundred and Fifty Qatari Riyals and Fifty Dirhams Only (QAR 1,250.50)
|
|
332
|
-
arqam("1.23456");
|
|
333
|
-
arqam("1.005", "ar-QA", {style: "currency"});
|
|
243
|
+
arqam("1.23456"); // واحد، ومائتان وخمسة وثلاثون جزءًا من الألف
|
|
244
|
+
arqam("1.005", "ar-QA", {style: "currency"}); // ريال قطري، ودرهم
|
|
334
245
|
arqam("1.005", "ar-QA", {style: "currency", roundingMode: "trunc"}); // ريال قطري
|
|
335
|
-
arqam("5", {signDisplay: "always"});
|
|
246
|
+
arqam("5", {signDisplay: "always"}); // موجب خمسة
|
|
336
247
|
```
|
|
337
248
|
|
|
338
249
|
<p align="left"><img src="https://arqampro.com/images/readme/example-date.png" width="690" alt="Arqam: 18/11/2026 in words with its Hijri date, in full tashkeel and in the compact form"></p>
|
|
@@ -342,15 +253,17 @@ As JavaScript's `Intl.NumberFormat`, one `arqam.NumberFormat` writes every langu
|
|
|
342
253
|
are there too.
|
|
343
254
|
|
|
344
255
|
```js
|
|
345
|
-
new arqam.NumberFormat("ar-QA", {style: "currency", currency: "QAR"}).format(1250.5);
|
|
346
|
-
|
|
256
|
+
new arqam.NumberFormat("ar-QA", {style: "currency", currency: "QAR"}).format(1250.5);
|
|
257
|
+
// ألف ومائتان وخمسون ريالًا قطريًا، وخمسون درهمًا
|
|
258
|
+
new arqam.NumberFormat("en-GB", {style: "currency", currency: "QAR"}).format(1250.5);
|
|
259
|
+
// One Thousand Two Hundred and Fifty Qatari Riyals and Fifty Dirhams
|
|
347
260
|
```
|
|
348
261
|
|
|
349
262
|
Pass amounts as text (`"1250.50"`): a JS number keeps only about 16 significant digits.
|
|
350
263
|
|
|
351
|
-
The rounding is Intl's: 3
|
|
352
|
-
|
|
353
|
-
`
|
|
264
|
+
The rounding is Intl's, half up: 3 places for a number, the currency's minor unit for an amount, and a whole number
|
|
265
|
+
for a percentage. `maximumFractionDigits` and `roundingMode: "trunc"` change it. The Arabic engine called directly
|
|
266
|
+
(`arqamAR.toWords`) cuts instead, unless you give `rounding: "on"`.
|
|
354
267
|
|
|
355
268
|
Each language has its own options beside Intl's: see
|
|
356
269
|
[Arabic](#the-arabic-engine-arqamar) and [English](https://github.com/MohsenAlyafei/arqam/blob/master/en/README.md).
|
|
@@ -389,73 +302,124 @@ And more:
|
|
|
389
302
|
```js
|
|
390
303
|
arqam("1250.50", "DZD", {prefix: "فقط", suffix: "لا غير"});
|
|
391
304
|
// فقط ألف ومائتان وخمسون دينارًا جزائريًا، وخمسون سنتيمًا لا غير
|
|
392
|
-
arqam.toWords("2000000", "DZD", {ierab: "jarr"});
|
|
393
|
-
arqam.toWords("2500", "LBP", {approx: "about"});
|
|
305
|
+
arqam.toWords("2000000", "DZD", {ierab: "jarr"}); // مليوني دينار جزائري
|
|
306
|
+
arqam.toWords("2500", "LBP", {approx: "about"}); // قرابة ألفين وخمسمائة ليرة لبنانية
|
|
394
307
|
arqam.toWords("1500", "ar-IQ", {style: "currency"}); // ألف وخمسمائة دينار عراقي
|
|
395
|
-
arqam.toWords("101000", {legal: "full"});
|
|
396
|
-
arqam.toWords("21", {style: "ordinal", ordinal: "feminine"});
|
|
397
|
-
arqam.toWords("25%");
|
|
308
|
+
arqam.toWords("101000", {legal: "full"}); // مائة ألف وألف
|
|
309
|
+
arqam.toWords("21", {style: "ordinal", ordinal: "feminine"}); // الحادية والعشرون
|
|
310
|
+
arqam.toWords("25%"); // خمسة وعشرون بالمائة
|
|
398
311
|
|
|
399
312
|
"في " + arqam.toDate("26/11/2026", {ierab: "jarr"});
|
|
400
313
|
// في السادس والعشرين من شهر نوفمبر لعام ألفين وستة وعشرين للميلاد
|
|
401
|
-
arqam.toTime("15:45");
|
|
402
|
-
arqam.toTime("15:45", {timeParts: "on"});
|
|
403
|
-
arqam.toFraction("3 1/2");
|
|
404
|
-
arqam.toFraction("3/4");
|
|
314
|
+
arqam.toTime("15:45"); // الساعة الثالثة وخمس وأربعون دقيقةً عصرًا
|
|
315
|
+
arqam.toTime("15:45", {timeParts: "on"}); // الساعة الرابعة إلا الربع عصرًا
|
|
316
|
+
arqam.toFraction("3 1/2"); // ثلاثة ونصف
|
|
317
|
+
arqam.toFraction("3/4"); // ثلاثة أرباع
|
|
405
318
|
```
|
|
406
319
|
|
|
407
320
|
<p align="left"><img src="https://arqampro.com/images/readme/example-time.png" width="690" alt="Arqam: the time 15:45 as a quarter to four, in coloured words"></p>
|
|
408
321
|
|
|
409
322
|
Arabic-Western and Arabic-Eastern numbers are both accepted, with `-` before and `%` after.
|
|
410
323
|
|
|
411
|
-
##
|
|
324
|
+
## Recipes
|
|
412
325
|
|
|
413
|
-
|
|
414
|
-
the same Arabic words:
|
|
326
|
+
One call for each common task.
|
|
415
327
|
|
|
416
328
|
```js
|
|
417
329
|
import arqam from "arqam";
|
|
418
|
-
//
|
|
419
|
-
import
|
|
330
|
+
import "arqam/en"; // English: adds itself to arqam
|
|
331
|
+
import "arqam/units"; // units of measure: adds itself to arqam.NumberFormat
|
|
332
|
+
import wordsToNumbers from "arqam/words";
|
|
333
|
+
|
|
334
|
+
// a cheque: the legal form, «فقط … لا غير» and the figure
|
|
335
|
+
arqam("15400.75", "QAR", {legal: "auto", prefix: "فقط", suffix: "لا غير", brackets: "end"});
|
|
336
|
+
// فقط خمسة عشر ألفًا وأربعمائة ريال قطري، وخمسة وسبعون درهمًا لا غير (15,400.75 QAR)
|
|
337
|
+
|
|
338
|
+
// a bilingual invoice
|
|
339
|
+
arqam.toBilingual("1250.50", "SAR").en;
|
|
340
|
+
// One Thousand Two Hundred and Fifty Saudi Riyals and Fifty Halalahs Only
|
|
341
|
+
|
|
342
|
+
// the case after a verb or a preposition: دفعتُ …
|
|
343
|
+
arqam("2000", "SAR", {ierab: "nasb"}); // ألفي ريال سعودي
|
|
344
|
+
|
|
345
|
+
// a date in both calendars
|
|
346
|
+
arqam.toDate("23/11/2026", {calendar: "both"});
|
|
347
|
+
// الثالث والعشرون من شهر نوفمبر لعام ألفين وستة وعشرين للميلاد، الموافق الثالث عشر من شهر جمادى الآخرة لعام ألف وأربعمائة وثمانية وأربعين للهجرة
|
|
348
|
+
|
|
349
|
+
// a time, an ordinal, an approximate amount, a unit
|
|
350
|
+
arqam.toTime("15:45"); // الساعة الثالثة وخمس وأربعون دقيقةً عصرًا
|
|
351
|
+
arqam("21", {ordinal: "feminine"}); // الحادية والعشرون
|
|
352
|
+
arqam("125", "MAD", {approx: "plus"}); // مائة ونيف وعشرون درهمًا مغربيًا
|
|
353
|
+
new arqam.NumberFormat("ar", {style: "unit", unit: "kilometer-per-hour"}).format(120);
|
|
354
|
+
// مائة وعشرون كيلومترًا في الساعة
|
|
355
|
+
|
|
356
|
+
// words back to a number, dialect included
|
|
357
|
+
wordsToNumbers("ألفين وخمسمية ريال"); // 2500 ريال
|
|
420
358
|
```
|
|
421
359
|
|
|
422
|
-
|
|
360
|
+
## Web API: tafqeet from any program
|
|
423
361
|
|
|
424
|
-
|
|
425
|
-
|
|
362
|
+
> [!TIP]
|
|
363
|
+
> **In JavaScript, use the library itself**, not the API: it needs no internet and no server, it is faster, and
|
|
364
|
+
> nothing you write leaves your device.
|
|
426
365
|
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
- **Full three-case inflection (iʿrāb):** nominative (rafʿ), accusative (naṣb) and genitive (jarr) across cardinals,
|
|
430
|
-
ordinals (الْأَوَّلُ / الْأَوَّلَ / الْأَوَّلِ), duals (مائتا / مائتي) and sound plurals (ـُونَ / ـِينَ).
|
|
431
|
-
- **Counted noun customisation:** four forms of the counted noun, case switching, ascending and descending word order,
|
|
432
|
-
and strict Classical/MSA grammar rules.
|
|
366
|
+
Arqam also answers over the web at **`https://api.arqampro.com`**, free and with no key, for programs that do not run
|
|
367
|
+
JavaScript: Excel, Python, PHP, C# and no-code tools.
|
|
433
368
|
|
|
434
|
-
|
|
369
|
+
```text
|
|
370
|
+
https://api.arqampro.com/v1/words?n=1250.50¤cy=SAR
|
|
371
|
+
```
|
|
435
372
|
|
|
436
|
-
|
|
373
|
+
```json
|
|
374
|
+
{ "input": "1250.50", "words": "ألف ومائتان وخمسون ريالًا سعوديًا، وخمسون هللةً", "version": "1.93" }
|
|
375
|
+
```
|
|
437
376
|
|
|
438
|
-
|
|
439
|
-
- Six tashkeel modes, written in Unicode's standard order.
|
|
440
|
-
- **Reverse parsing (`arqam/words`):** dialect-tolerant conversion from Arabic words back to numbers.
|
|
441
|
-
- **Grammar breakdown (`arqam/explain`):** a word-by-word morphological and syntactic explainer.
|
|
377
|
+
`version` is the Arabic engine's version (`arqamEngine` in `package.json`), not the npm package's.
|
|
442
378
|
|
|
443
|
-
|
|
379
|
+
| Call | Gives |
|
|
380
|
+
|---|---|
|
|
381
|
+
| `/v1/words?n=…` | a number or amount in Arabic words |
|
|
382
|
+
| `/v1/bilingual?n=…¤cy=…` | Arabic and English at once, in the cheque form |
|
|
383
|
+
| `/v1/english?n=…` | a number or amount in English words |
|
|
384
|
+
| `/v1/date?d=23/11/2026` | a date in words (`calendar=g`, `h` or `b`) |
|
|
385
|
+
| `/v1/time?t=15:45` | a time in words |
|
|
386
|
+
| `/v1/fraction?f=3%2F4` | a fraction in words (`fractionForm`, `fractionOf=…` for «ثلثا المبلغ») |
|
|
387
|
+
| `/v1/value?text=…` | Arabic words back to their number (`fractions=on`: «ثلاثة أرباع» → `3/4`) |
|
|
388
|
+
| `/v1/explain?n=…` | the إعراب of each word |
|
|
444
389
|
|
|
445
|
-
|
|
446
|
-
|
|
390
|
+
The options are the library's own (`currency`, `tashkeel`, `ierab`, `legal`, `wordOrder` …); `format=text` gives the
|
|
391
|
+
words alone. Excel for Windows, with the amount in A2:
|
|
447
392
|
|
|
448
|
-
|
|
393
|
+
```text
|
|
394
|
+
=WEBSERVICE("https://api.arqampro.com/v1/words?n="&A2&"¤cy=SAR&format=text")
|
|
449
395
|
```
|
|
450
396
|
|
|
397
|
+
```python
|
|
398
|
+
import requests
|
|
399
|
+
r = requests.get("https://api.arqampro.com/v1/words", params={"n": "1250.50", "currency": "SAR"})
|
|
400
|
+
print(r.json()["words"])
|
|
401
|
+
```
|
|
451
402
|
|
|
452
|
-
|
|
403
|
+
Every call, its options and examples for PHP, C# and curl: [the API page](https://arqampro.com/en/tafqeet/api/).
|
|
453
404
|
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
405
|
+
## The Arabic engine (arqamAR)
|
|
406
|
+
|
|
407
|
+
Arabic is the default language. The default export (`arqam`) and the named export (`arqamAR`) give the same calls and
|
|
408
|
+
the same Arabic words:
|
|
409
|
+
|
|
410
|
+
```js
|
|
411
|
+
import arqam from "arqam";
|
|
412
|
+
// or
|
|
413
|
+
import {arqamAR} from "arqam";
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
It writes cardinals and ordinals by the rules of Arabic grammar. The numbers 3 to 10 take the opposite gender of the
|
|
417
|
+
counted noun. The dual loses its ن in iḍāfa (مائتا ألف، ألفا ريال). Every number takes the three cases, and the counted
|
|
418
|
+
noun takes its four forms: singular, dual, plural, and the accusative singular after 11 to 99. Ordinals run to 999,999
|
|
419
|
+
and follow the Basran rule for iḍāfa (مائة الألف، مائتا الألف).
|
|
420
|
+
|
|
421
|
+
**What's new since `arqam@1`:** the three cases, ordinals to 999,999, six tashkeel modes, words back to numbers
|
|
422
|
+
(`arqam/words`) and the grammar of each word (`arqam/explain`).
|
|
459
423
|
|
|
460
424
|
## Specifications
|
|
461
425
|
|
|
@@ -464,27 +428,27 @@ into numbers, checks words against their figure, and explains the grammar of eve
|
|
|
464
428
|
|
|
465
429
|
| Feature | Arqam |
|
|
466
430
|
|---|---|
|
|
467
|
-
| Whole digits | No limit
|
|
468
|
-
| Decimal places | No limit
|
|
469
|
-
| Input digits | Arabic-Western (0–9), Arabic-Eastern (٠–٩) and Persian (۰–۹)
|
|
431
|
+
| Whole digits | No limit. Give the number as text or a BigInt. Words back to numbers reads up to 36 digits |
|
|
432
|
+
| Decimal places | No limit. An amount is rounded half up to its currency's places; `roundingMode: "trunc"` cuts instead |
|
|
433
|
+
| Input digits | Arabic-Western (0–9), Arabic-Eastern (٠–٩) and Persian (۰–۹). The decimal mark is `.` or `٫`. Leave out thousands separators: pass `"1250.5"` |
|
|
470
434
|
| Scales | Arabic (مليار), short (بليون) and long (European), with `scale` |
|
|
471
435
|
| Output numerals | Arabic-Western or Arabic-Eastern, with `arabicNumbers` |
|
|
472
436
|
| Currencies | 188 built in, plus your own with `registerCurrency` |
|
|
473
437
|
| Units of measure | 304 built in (`arqam/units`) |
|
|
474
|
-
| Ordinals | 1 to 999,999
|
|
475
|
-
| Approximate quantities | Seven forms with `approx
|
|
438
|
+
| Ordinals | 1 to 999,999, with gender and the three cases. Follows the Basran rule for iḍāfa |
|
|
439
|
+
| Approximate quantities | Seven forms with `approx`, each in the right gender and case: about (قرابة), over (ما يزيد على), under (أقل من), at least (ما لا يقل عن), at most (ما لا يزيد على), few (بضعة) and plus (نيّف) |
|
|
476
440
|
| Dates and times | Gregorian and Hijri (Umm al-Qura) dates, times, time zones, styles, durations and ranges |
|
|
477
|
-
| Grammar | Gender polarity of 3–10
|
|
478
|
-
| Words back to numbers, `verify()` | Reads Fuṣḥā (الفصحى) and colloquial Arabic
|
|
479
|
-
| Grammar explainer |
|
|
441
|
+
| Grammar | Gender polarity of 3–10. The three cases. The dual, which loses its ن in iḍāfa. The four forms of the counted noun. Six tashkeel modes. Word order |
|
|
442
|
+
| Words back to numbers, `verify()` | Reads Fuṣḥā (الفصحى) and colloquial Arabic back into digits, whatever the hamza (`arqam/words`). `verify()` reports what differs |
|
|
443
|
+
| Grammar explainer | The إعراب of each word, with its rule (`arqam/explain`). The [playground](https://arqampro.com/docs/playground.html) writes the call for you |
|
|
480
444
|
| Intl-style API | `NumberFormat`: `format`, `formatToParts`, `formatRange` |
|
|
481
445
|
| Languages | Arabic (built in) and English (`arqam/en`), each its own engine; more as modules |
|
|
482
446
|
| Documents | Cheque, invoice, receipt and contract wording, in Arabic, English or both (`toClause`) |
|
|
483
447
|
| Dependencies | None; no network calls |
|
|
484
|
-
| Data privacy |
|
|
448
|
+
| Data privacy | Everything runs on your device. Nothing you type is sent anywhere, in the library or on [arqampro.com](https://arqampro.com) |
|
|
485
449
|
| Runs in | Every current browser (modules or a plain `<script>`), Node 14.13+, Deno and bundlers |
|
|
486
450
|
| TypeScript | Full declarations (`dist/*.d.mts`) |
|
|
487
|
-
| Size | Engine 261.4 KB (79.4 KB gzipped)
|
|
451
|
+
| Size | Engine 261.4 KB (79.4 KB gzipped). Each add-on is a separate file, loaded only if you use it |
|
|
488
452
|
| Licence | MIT |
|
|
489
453
|
|
|
490
454
|
</details>
|
|
@@ -496,47 +460,49 @@ into numbers, checks words against their figure, and explains the grammar of eve
|
|
|
496
460
|
|
|
497
461
|
| Call | Gives |
|
|
498
462
|
|---|---|
|
|
499
|
-
| `toWords(number, [locales], [options])` | the words, as `number.toLocaleString(locales, options)
|
|
463
|
+
| `toWords(number, [locales], [options])` | the words, as `number.toLocaleString(locales, options)` would give figures. An array gives an array |
|
|
500
464
|
| `toParts(number, [options])` | the same words in parts: `prefix`, `sign`, `whole`, `fraction`, `suffix`, `brackets`, `figure`… |
|
|
501
|
-
| `toDate(date, [options])` | a date in words: Gregorian, Hijri or both
|
|
502
|
-
| `toTime(time, [options])` | a time in words
|
|
465
|
+
| `toDate(date, [options])` | a date in words: Gregorian, Hijri or both. Styles `words`, `ordinal` and `compact`. Gulf, Levant or Maghreb month names |
|
|
466
|
+
| `toTime(time, [options])` | a time in words. Styles `common`, `exact` (صباحًا / مساءً), `h24` and `duration` (ساعتان ونصف). Can add the part of the day and the time zone |
|
|
503
467
|
| `toDateTime(moment, [options])` | a date with its time and time zone, in one phrase |
|
|
504
|
-
| `toFraction(fraction, [options])` | a
|
|
505
|
-
| `NumberFormat([locales], [options])` | Intl's formatter in words: `format()`, `formatToParts()`, `formatRange()
|
|
468
|
+
| `toFraction(fraction, [options])` | a fraction in words: 3/4 → ثلاثة أرباع، 3 1/2 → ثلاثة ونصف |
|
|
469
|
+
| `NumberFormat([locales], [options])` | Intl's formatter, in words: `format()`, `formatToParts()`, `formatRange()` and `resolvedOptions()`. It rounds as Intl does |
|
|
506
470
|
| `config(options)` | standing options for the calls that follow |
|
|
507
|
-
| `createArqam([options])` | an instance with its own options
|
|
471
|
+
| `createArqam([options])` | an instance with its own options, for example one per user on a server |
|
|
508
472
|
| `removeTashkeel(text, [options])` | any Arabic text without its tashkeel (113 marks) |
|
|
509
473
|
| `nisba(name, [{feminine}])` | the نسبة adjective of a place name: قطر → قطري، كوريا الشمالية → كوري شمالي |
|
|
510
474
|
| `registerCurrency(code, attributes)` | add or change a currency (or a counted noun) for the session |
|
|
511
475
|
| `registerTimeZone(zone, name)` | give an Arabic name to a time zone that is not on the built-in list |
|
|
512
|
-
| `utils` | the building blocks
|
|
476
|
+
| `utils` | the building blocks, such as `count` (any counted noun), `ordinal`, `parseDate`, `hijri`, `toCase` and `options` (every option) |
|
|
513
477
|
| `reset()`, `options()`, `version`, `currencies`, `regions`, `timeZones`, `defaults`, `optionNames` | state and tables |
|
|
514
478
|
| `toBilingual(number, code, [options])` | the amount in Arabic and English, with the figure: `{ar, en, figure}` (with `arqam/en`) |
|
|
515
479
|
| `toLanguages(number, code, languages, [options])` | the same for any languages loaded: `{ar, en, …, figure}` |
|
|
516
|
-
| `toClause(kind, number, code, [options])` | the wording
|
|
480
|
+
| `toClause(kind, number, code, [options])` | the wording for a cheque, invoice, receipt or contract, in Arabic, English or both |
|
|
517
481
|
| `NumberFormat.supportedLocalesOf(locales)` | the locales of a language that is loaded (English with `arqam/en`) |
|
|
518
482
|
|
|
519
483
|
```js
|
|
520
|
-
arqam.utils.count(11, {single: "سيارة", plural: "سيارات", gender: "feminine"});
|
|
521
|
-
|
|
484
|
+
arqam.utils.count(11, {single: "سيارة", plural: "سيارات", gender: "feminine"});
|
|
485
|
+
// إحدى عشرة سيارةً
|
|
486
|
+
arqam.utils.toCase("السادس والعشرون", "jarr"); // السادس والعشرين
|
|
522
487
|
arqam.removeTashkeel("أَلْفٌ وَمِائَتَانِ"); // ألف ومائتان
|
|
523
|
-
arqam.nisba("قطر");
|
|
488
|
+
arqam.nisba("قطر"); // قطري
|
|
524
489
|
```
|
|
525
490
|
|
|
526
491
|
```js
|
|
527
492
|
import {toWords, toParts, createArqam} from "arqam";
|
|
528
493
|
|
|
529
|
-
toWords("11", {ordinal: "f"});
|
|
530
|
-
toWords("21", {ordinal: "m", ordinalDefinite: "off"});
|
|
531
|
-
toWords("1250", {currency: "EGP", wordOrder: "small"});
|
|
532
|
-
|
|
494
|
+
toWords("11", {ordinal: "f"}); // الحادية عشرة
|
|
495
|
+
toWords("21", {ordinal: "m", ordinalDefinite: "off"}); // حاد وعشرون (without الـ)
|
|
496
|
+
toWords("1250", {currency: "EGP", wordOrder: "small"});
|
|
497
|
+
// خمسون ومائتان وألف جنيه مصري (the classical order)
|
|
498
|
+
toParts("-1250.5", {currency: "EGP"}).whole; // ألف ومائتين وخمسين جنيهًا مصريًا (after سالب)
|
|
533
499
|
|
|
534
500
|
const kw = createArqam({currency: "KWD"});
|
|
535
|
-
kw.toWords("2.5");
|
|
501
|
+
kw.toWords("2.5"); // ديناران كويتيان، وخمسمائة فلس
|
|
536
502
|
```
|
|
537
503
|
|
|
538
|
-
`toWords
|
|
539
|
-
|
|
504
|
+
`toWords(number, [locales], [options])` is the same as `arqam(…)` and `arqam.toWords(…)`. A currency code in place of
|
|
505
|
+
the locale makes the number an amount: `toWords(number, "QAR", [options])`.
|
|
540
506
|
|
|
541
507
|
</details>
|
|
542
508
|
|
|
@@ -565,10 +531,17 @@ used most:
|
|
|
565
531
|
| `locale` | `"ar"`, `"ar-QA"` … the 22 Arab League locales | the region's currency, month names, digits, separators and time zone |
|
|
566
532
|
| `timeZone`, `zoneName` | an IANA name; city / country / offset / both / off | the time zone of an exact moment, and how it is named |
|
|
567
533
|
|
|
568
|
-
Coded values take a readable name or a short code:
|
|
569
|
-
|
|
570
|
-
`
|
|
571
|
-
|
|
534
|
+
Coded values take a readable name or a short code:
|
|
535
|
+
|
|
536
|
+
- `tashkeel`: none, alif, fatha, tanween, endings, full (or `""`, `a`, `h`, `t`, `p`, `f`)
|
|
537
|
+
- `ierab`: raf, nasb, jarr
|
|
538
|
+
- `legal`: none, auto, full
|
|
539
|
+
- `numSymbol`: code, english, native, sign, name, none
|
|
540
|
+
- `decFormat`: auto, words, figures, digits, words-words, words-figures, figures-words, figures-figures, decimal, slash
|
|
541
|
+
- `ordinal`: masculine, feminine
|
|
542
|
+
|
|
543
|
+
Older names still work, so existing code does not break: for `numSymbol`, `latin` means `english` and `symbol` means
|
|
544
|
+
`native`.
|
|
572
545
|
|
|
573
546
|
A misspelt option or a bad value throws a `TypeError` that says what is wrong ("did you mean tashkeel?").
|
|
574
547
|
With `strict: "on"`, a number or date that cannot be written throws too, instead of returning `""`.
|
|
@@ -582,14 +555,15 @@ the options; `new` is optional.
|
|
|
582
555
|
|
|
583
556
|
```js
|
|
584
557
|
import {NumberFormat} from "arqam";
|
|
585
|
-
import "arqam/units";
|
|
558
|
+
import "arqam/units"; // only for style "unit"; adds itself to arqam.NumberFormat
|
|
586
559
|
|
|
587
560
|
new NumberFormat("ar-QA", {style: "currency"}).format(1234.5);
|
|
588
561
|
// ألف ومائتان وأربعة وثلاثون ريالًا قطريًا، وخمسون درهمًا (the currency of the locale's country)
|
|
589
|
-
NumberFormat({style: "percent", maximumFractionDigits: 1}).format(0.125);
|
|
562
|
+
NumberFormat({style: "percent", maximumFractionDigits: 1}).format(0.125);
|
|
563
|
+
// اثنا عشر فاصلة خمسة بالمائة
|
|
590
564
|
NumberFormat({style: "unit", unit: "kilometer"}).format(12.5); // اثنا عشر كيلومترًا، وخمسمائة متر
|
|
591
|
-
NumberFormat({style: "ordinal", ordinal: "feminine"}).format(21);
|
|
592
|
-
[1, 2, 3].map(NumberFormat({style: "ordinal"}).format);
|
|
565
|
+
NumberFormat({style: "ordinal", ordinal: "feminine"}).format(21); // الحادية والعشرون
|
|
566
|
+
[1, 2, 3].map(NumberFormat({style: "ordinal"}).format); // ["الأول", "الثاني", "الثالث"]
|
|
593
567
|
NumberFormat({style: "currency", currency: "QAR"}).formatRange(1000, 2000);
|
|
594
568
|
// من ألف ريال قطري إلى ألفي ريال قطري
|
|
595
569
|
NumberFormat({style: "date"}).formatRange("2026-11-01", "2026-11-15");
|
|
@@ -617,7 +591,8 @@ times, data, electrical units, pressure, energy, flow, fuel use and more. A unit
|
|
|
617
591
|
(`"kilometer-per-hour"`), its key (`"E04"`) or its Arabic name (`"كيلومتر في الساعة"`).
|
|
618
592
|
|
|
619
593
|
```js
|
|
620
|
-
arqam.NumberFormat({style: "unit", unit: "kilometer-per-hour"}).format(120);
|
|
594
|
+
arqam.NumberFormat({style: "unit", unit: "kilometer-per-hour"}).format(120);
|
|
595
|
+
// مائة وعشرون كيلومترًا في الساعة
|
|
621
596
|
```
|
|
622
597
|
|
|
623
598
|
<p align="left"><img src="https://arqampro.com/images/readme/example-unit.png" width="690" alt="Arqam: 120 kilometres per hour, in coloured words"></p>
|
|
@@ -637,7 +612,8 @@ airline hubs are named too, and `registerTimeZone()` names any other zone. The z
|
|
|
637
612
|
```js
|
|
638
613
|
arqam.toDateTime("2026-11-24T06:15:00Z", {locale: "ar-SA"});
|
|
639
614
|
// الرابع والعشرون من شهر نوفمبر لعام ألفين وستة وعشرين للميلاد، الساعة التاسعة وخمس عشرة دقيقةً صباحًا بتوقيت مكة المكرمة
|
|
640
|
-
arqam.toTime("2026-11-24T06:15:00Z", {timeZone: "Europe/London"});
|
|
615
|
+
arqam.toTime("2026-11-24T06:15:00Z", {timeZone: "Europe/London"});
|
|
616
|
+
// الساعة السادسة وخمس عشرة دقيقةً صباحًا بتوقيت لندن
|
|
641
617
|
```
|
|
642
618
|
|
|
643
619
|
<p align="left"><img src="https://arqampro.com/images/readme/example-datetime.png" width="690" alt="Arqam: 24 November 2026, 9:15 in the morning, Makkah time, in coloured words"></p>
|
|
@@ -648,15 +624,15 @@ When the exact figure is not wanted, or not known, `approx` writes the number as
|
|
|
648
624
|
gender and case:
|
|
649
625
|
|
|
650
626
|
```js
|
|
651
|
-
arqam("2500", "LBP", {approx: "about"});
|
|
652
|
-
arqam("2500", "LBP", {approx: "over"});
|
|
653
|
-
arqam("2500", "LBP", {approx: "under"});
|
|
627
|
+
arqam("2500", "LBP", {approx: "about"}); // قرابة ألفين وخمسمائة ليرة لبنانية
|
|
628
|
+
arqam("2500", "LBP", {approx: "over"}); // ما يزيد على ألفين وخمسمائة ليرة لبنانية
|
|
629
|
+
arqam("2500", "LBP", {approx: "under"}); // أقل من ألفين وخمسمائة ليرة لبنانية
|
|
654
630
|
arqam("2500", "LBP", {approx: "atLeast"}); // ما لا يقل عن ألفين وخمسمائة ليرة لبنانية
|
|
655
|
-
arqam("2500", "LBP", {approx: "atMost"});
|
|
656
|
-
arqam("5000", "IQD", {approx: "few"});
|
|
657
|
-
arqam("300", "DZD", {approx: "few"});
|
|
658
|
-
arqam("15", "SDG", {approx: "few"});
|
|
659
|
-
arqam("125", "MAD", {approx: "plus"});
|
|
631
|
+
arqam("2500", "LBP", {approx: "atMost"}); // ما لا يزيد على ألفين وخمسمائة ليرة لبنانية
|
|
632
|
+
arqam("5000", "IQD", {approx: "few"}); // بضعة آلاف دينار عراقي
|
|
633
|
+
arqam("300", "DZD", {approx: "few"}); // بضع مئات من الدنانير الجزائرية
|
|
634
|
+
arqam("15", "SDG", {approx: "few"}); // بضعة عشر جنيهًا سودانيًا
|
|
635
|
+
arqam("125", "MAD", {approx: "plus"}); // مائة ونيف وعشرون درهمًا مغربيًا
|
|
660
636
|
```
|
|
661
637
|
|
|
662
638
|
<p align="left"><img src="https://arqampro.com/images/readme/example-approx6.png" width="690" alt="Arqam: six ways to write an approximate amount, in coloured words"></p>
|
|
@@ -669,6 +645,33 @@ arqam("125", "MAD", {approx: "plus"}); // مائة ونيف وعشرون
|
|
|
669
645
|
|
|
670
646
|
A number that neither fits gives `""`; with `strict: "on"` it throws a `RangeError`.
|
|
671
647
|
|
|
648
|
+
## Fractions
|
|
649
|
+
|
|
650
|
+
A fraction is written as you type it: `3/4`, `3 1/2`, `3½`, `-3/4`. Halves to tenths are named (ثلث، ربع … عشر, with a
|
|
651
|
+
damma on the second letter in full tashkeel); above tenths a fraction is «أجزاء من». A value of one or more is a mixed
|
|
652
|
+
number unless `fractionMixed: "off"`.
|
|
653
|
+
|
|
654
|
+
```js
|
|
655
|
+
arqam("3/4"); // ثلاثة أرباع
|
|
656
|
+
arqam("3½"); // ثلاثة ونصف
|
|
657
|
+
arqam("-3/4"); // سالب ثلاثة أرباع
|
|
658
|
+
arqam.toFraction("7/16"); // سبعة أجزاء من ستة عشر
|
|
659
|
+
arqam.toFraction("5/3", {fractionMixed: "off"}); // خمسة أثلاث
|
|
660
|
+
arqam.toFraction("3/4", {fractionForm: "math"}); // ثلاثة على أربعة
|
|
661
|
+
```
|
|
662
|
+
|
|
663
|
+
A fraction of a noun (`fractionOf`): the fraction takes the case you ask for and your words follow it exactly as you give
|
|
664
|
+
them. With a currency the exact amount is written in the small unit, or the fraction is named with `fractionUnit: "named"`:
|
|
665
|
+
|
|
666
|
+
```js
|
|
667
|
+
arqam.toFraction("2/3", {fractionOf: "المبلغ", ierab: "nasb"}); // ثلثي المبلغ
|
|
668
|
+
arqam.toFraction("2/3", {fractionOf: "الْمَبْلَغِ", ierab: "nasb", tashkeel: "full"}); // ثُلُثَيِ الْمَبْلَغِ
|
|
669
|
+
arqam.toFraction("3/4", {currency: "QAR"}); // خمسة وسبعون درهمًا قطريًا
|
|
670
|
+
arqam.toFraction("3/4", {currency: "QAR", fractionUnit: "named"}); // ثلاثة أرباع ريال قطري
|
|
671
|
+
```
|
|
672
|
+
|
|
673
|
+
The fraction words in every form, case and tashkeel level are in the [golden book](https://github.com/MohsenAlyafei/arqam/blob/master/golden/README.md)'s fraction files.
|
|
674
|
+
|
|
672
675
|
## Words back to numbers
|
|
673
676
|
|
|
674
677
|
`arqam/words` reads Arabic number words in any text (dialects too), with fractions, currencies and a cheque check. It is
|
|
@@ -677,11 +680,14 @@ a sub-library: it uses the engine's own functions, and importing it brings the e
|
|
|
677
680
|
```js
|
|
678
681
|
import wordsToNumbers, {find, verify} from "arqam/words";
|
|
679
682
|
|
|
680
|
-
wordsToNumbers("لدي ألفان وخمسمائة ريال وخمستاشر كتاب");
|
|
681
|
-
wordsToNumbers("
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
683
|
+
wordsToNumbers("لدي ألفان وخمسمائة ريال وخمستاشر كتاب"); // لدي 2500 ريال و15 كتاب
|
|
684
|
+
wordsToNumbers("دفعت ثلاثة أرباع المبلغ"); // دفعت 3/4 المبلغ
|
|
685
|
+
wordsToNumbers("سبعة أجزاء من ستة عشر", {fractions: "on"}); // 7/16
|
|
686
|
+
wordsToNumbers("ألف، ومائتان وخمسون ريالًا قطريًا، وخمسون درهمًا", {currency: "code"});
|
|
687
|
+
// 1250.50 QAR
|
|
688
|
+
verify("فقط ألف ومائتان وخمسون ريالًا قطريًا لا غير", "1250", {currency: "QAR"}).ok; // true
|
|
689
|
+
verify("ألف ريال قطري، وخمسون درهما", "1250.75", {currency: "QAR"}).issue; // both
|
|
690
|
+
verify("ألف ريال قطري، وخمسون درهما", "1250.75", {currency: "QAR"}).difference; // -250.25
|
|
685
691
|
verify("ألف ريال قطري، وخمسون درهما", "1250.75", {currency: "QAR"}).expectedWords;
|
|
686
692
|
// ألف ومائتان وخمسون ريالًا قطريًا، وخمسة وسبعون درهمًا
|
|
687
693
|
```
|
|
@@ -702,7 +708,8 @@ the page.
|
|
|
702
708
|
|
|
703
709
|
```js
|
|
704
710
|
import {explain} from "arqam/explain";
|
|
705
|
-
explain("13", {currency: "SYP"}).words[0].why;
|
|
711
|
+
explain("13", {currency: "SYP"}).words[0].why;
|
|
712
|
+
// الجزء الأول من 13 يخالف المعدود: «ليرة» مؤنث فجاء بلا تاء.
|
|
706
713
|
```
|
|
707
714
|
|
|
708
715
|
|
|
@@ -719,8 +726,10 @@ The figures in brackets are Arabic-Western numbers (0123456789) by default; `ara
|
|
|
719
726
|
Arabic-Western numbers everywhere else; `arabicNumbers` changes it either way:
|
|
720
727
|
|
|
721
728
|
```js
|
|
722
|
-
arqam.toWords("1250.5", "ar-SA", {style: "currency", brackets: "end"});
|
|
723
|
-
|
|
729
|
+
arqam.toWords("1250.5", "ar-SA", {style: "currency", brackets: "end"});
|
|
730
|
+
// ألف ومائتان وخمسون ريالًا سعوديًا، وخمسون هللةً (١٬٢٥٠٫٥٠ SAR)
|
|
731
|
+
arqam.toWords("1250.5", "ar-KW", {style: "currency", brackets: "end"});
|
|
732
|
+
// ألف ومائتان وخمسون دينارًا كويتيًا، وخمسمائة فلس (1,250.500 KWD)
|
|
724
733
|
arqam.toWords("1250.5", "ar-KW", {style: "currency", arabicNumbers: "eastern", brackets: "end"});
|
|
725
734
|
// ألف ومائتان وخمسون دينارًا كويتيًا، وخمسمائة فلس (١٬٢٥٠٫٥٠٠ KWD)
|
|
726
735
|
```
|
|
@@ -755,7 +764,7 @@ The number of decimals of each currency comes from Arqam's one currency table, s
|
|
|
755
764
|
|
|
756
765
|
```js
|
|
757
766
|
import arqam from "arqam";
|
|
758
|
-
import "arqam/en";
|
|
767
|
+
import "arqam/en"; // English: adds itself to arqam, so it needs no name
|
|
759
768
|
|
|
760
769
|
arqam.NumberFormat.supportedLocalesOf(["ar-QA", "en-GB", "fr-FR"]); // ["ar-QA","en-GB"]
|
|
761
770
|
```
|
|
@@ -765,8 +774,10 @@ arqam.NumberFormat.supportedLocalesOf(["ar-QA", "en-GB", "fr-FR"]); // ["ar-QA
|
|
|
765
774
|
Both languages at once, as on a bilingual cheque or contract:
|
|
766
775
|
|
|
767
776
|
```js
|
|
768
|
-
arqam.toBilingual("1250.50", "QAR").ar;
|
|
769
|
-
|
|
777
|
+
arqam.toBilingual("1250.50", "QAR").ar;
|
|
778
|
+
// فقط ألف ومائتان وخمسون ريالًا قطريًا، وخمسون درهمًا لا غير
|
|
779
|
+
arqam.toBilingual("1250.50", "QAR").en;
|
|
780
|
+
// One Thousand Two Hundred and Fifty Qatari Riyals and Fifty Dirhams Only
|
|
770
781
|
arqam.toBilingual("1250.50", "QAR").figure; // 1,250.50 QAR
|
|
771
782
|
```
|
|
772
783
|
|
|
@@ -821,6 +832,33 @@ See [the library's manual](https://arqampro.com/docs/manual.html#s6).
|
|
|
821
832
|
- **Size (gzipped in brackets):** engine 261.4 KB (79.4 KB), words to numbers 107.2 KB (29.5 KB), «اشرح» 120.0 KB
|
|
822
833
|
(30.9 KB), units 59.1 KB (9.8 KB), English 57.4 KB (18.8 KB). Load only what you use.
|
|
823
834
|
|
|
835
|
+
### TypeScript
|
|
836
|
+
|
|
837
|
+
The types check every option and its value, so a misspelt option is a compile error, not a silent mistake at run
|
|
838
|
+
time.
|
|
839
|
+
|
|
840
|
+
```ts
|
|
841
|
+
import arqam, { type ArqamOptions } from "arqam";
|
|
842
|
+
|
|
843
|
+
const cheque: ArqamOptions = {
|
|
844
|
+
currency: "QAR",
|
|
845
|
+
tashkeel: "alif",
|
|
846
|
+
ierab: "raf",
|
|
847
|
+
prefix: "فقط",
|
|
848
|
+
suffix: "لا غير",
|
|
849
|
+
brackets: "end",
|
|
850
|
+
};
|
|
851
|
+
|
|
852
|
+
const words: string = arqam("15400.75", cheque);
|
|
853
|
+
// فقط خمسة عشر ألفًا وأربعمائة ريال قطري، وخمسة وسبعون درهمًا لا غير (15,400.75 QAR)
|
|
854
|
+
|
|
855
|
+
const wrong: ArqamOptions = { currency: "QAR", tashkeal: "full" };
|
|
856
|
+
// error TS2561: … 'tashkeal' does not exist in type 'ArqamOptions'. Did you mean to write 'tashkeel'?
|
|
857
|
+
```
|
|
858
|
+
|
|
859
|
+
Every option is typed with its values, so `ierab: "nominative"` is an error too (the values are `"raf"`, `"nasb"`,
|
|
860
|
+
`"jarr"` and their short codes).
|
|
861
|
+
|
|
824
862
|
## Documentation and online tools
|
|
825
863
|
|
|
826
864
|
| | |
|
|
@@ -875,9 +913,9 @@ engine as the npm package, with a code editor beside it:
|
|
|
875
913
|
| [`ar/`](https://github.com/MohsenAlyafei/arqam/blob/master/ar/) | the README of the Arabic engine `arqamAR` (its code is in `src/`) |
|
|
876
914
|
| [`en/`](https://github.com/MohsenAlyafei/arqam/blob/master/en/) | the English engine `arqamEN`, and its README |
|
|
877
915
|
| [`extras/`](https://github.com/MohsenAlyafei/arqam/blob/master/extras/) | standalone helpers (scale names, ordinals, tashkeel and hamza removal, نسبة) and earlier work |
|
|
878
|
-
| [`tests/`](https://github.com/MohsenAlyafei/arqam/blob/master/tests/) | the library tests
|
|
916
|
+
| [`tests/`](https://github.com/MohsenAlyafei/arqam/blob/master/tests/) | the library's tests: `npm test` |
|
|
879
917
|
| [`tools/`](https://github.com/MohsenAlyafei/arqam/blob/master/tools/) | the build tools for `dist/` and the units add-on |
|
|
880
|
-
| [`js/`](https://github.com/MohsenAlyafei/arqam/blob/master/js/) | the currency and unit tables the units add-on
|
|
918
|
+
| [`js/`](https://github.com/MohsenAlyafei/arqam/blob/master/js/) | the currency and unit tables the units add-on is built from (shared with the page) |
|
|
881
919
|
| [`docs/`](https://github.com/MohsenAlyafei/arqam/blob/master/docs/) | `DEVELOPER.md` |
|
|
882
920
|
|
|
883
921
|
The Arqam page, manual and playground are published on [arqampro.com](https://arqampro.com).
|