Manual: the library
Manual: the library
Arqam writes numbers, amounts, dates and documents in words, in Arabic and English. This manual is the library's: the names, loading it, the calls that join languages and documents. Each language has its own manual: Arabic (arqamAR), English (arqamEN).
1. One library, many languages
arqam is the library. Each language is an engine of its own, named arqam with the language's two-letter ISO 639-1 code in capitals, reached through arqam by its locale, as in Intl. Arabic is the default: arqam(n, locales, options) and new arqam.NumberFormat(locales, options) take Intl's shape, and the other calls of arqam are Arabic.
| Code | Language | Engine | Module | Locales | Manual | README |
|---|---|---|---|---|---|---|
ar | Arabic | arqamAR | built in | ar, ar-QA, ar-SA … (the default) | arqamAR-manual.html | ar/README.md |
en | English | arqamEN | arqam/en | en-US, en-GB, en-IN … | arqamEN-manual.html | en/README.md |
What joins the languages lives in the library only, never in one language engine: toBilingual(), toLanguages() and toClause(). The amount, its decimals, its figure and the dates come from Arqam's one currency table and calendar, so every language writes the same amount and the same day.
2. The names
Every language engine is arqam + its code in capitals: arqamAR, arqamEN, and later arqamFR, arqamDE … They are the names of the files to load; the calls go through arqam, and the locale chooses the language, as in Intl. arqam.NumberFormat.supportedLocalesOf(locales) gives the locales of the languages loaded.
arqam("1250.50", "ar-QA", {style: "currency"})arqam("1250.50", "en-GB", {currency: "QAR"})arqam.NumberFormat.supportedLocalesOf(["ar", "en", "fr"])arqam("5", {currency: "QAR"})A language engine loaded on its own puts itself in one shared table, keyed by Symbol.for("arqam.languages"), so the library finds it however the files were loaded (plain scripts in any order, or ES modules). The table adds no global name.
One NumberFormat for every language
As JavaScript's one Intl.NumberFormat, the library's arqam.NumberFormat chooses the language from the locale: the first locale of the list whose language is loaded decides, and the call goes to that language's engine, with its options and checks. arqam(n, locales, options) gives the words of its format(n), as n.toLocaleString(locales, options); the rounding is Intl's (3 places for a number, the currency's minor unit, a whole percentage, half up). With no locale it is Arabic, as arqam is. A language that is not loaded, or that Arqam does not write, is a RangeError that says so.
new arqam.NumberFormat("ar-QA", {currency: "QAR"}).format(1250.5)new arqam.NumberFormat("en-GB", {currency: "QAR"}).format(1250.5)new arqam.NumberFormat("en-IN", {currency: "INR"}).format(123456)new arqam.NumberFormat({currency: "QAR"}).format(5)new arqam.NumberFormat(["fr-FR", "en-GB", "ar-QA"]).format(21)arqam.NumberFormat.supportedLocalesOf(["ar-QA", "en-GB", "fr-FR"])new arqam.NumberFormat("fr-FR")3. Install and load
npm install arqam import arqam from "arqam"; // the library: Arabic by default import "arqam/en"; // English, by its locale (en-GB, en-US …) import arqamWordsToNumbers from "arqam/words"; // Arabic words back to numbers import arqamExplain from "arqam/explain"; // «اشرح»: the grammar of every word import arqamUnits from "arqam/units"; // 252 units of measure
As plain scripts (no build step), in this order: the Arabic engine first, then what you need. arqamAR.js gives the two names arqam and arqamAR; arqamEN.js adds English to the library.
<script src="src/arqamAR.js"></script>
<script src="en/arqamEN.js"></script>
<script>
document.title = arqam("1250.50", "ar-QA", {style: "currency"}) + " · " + arqam("1250.50", "en-GB", {currency: "QAR"});
</script>
| Module | What it is |
|---|---|
arqam | the library (default export) and the Arabic engine (named export arqamAR) |
arqam/en | the English engine, arqamEN |
arqam/words | Arabic words back to numbers (fromWords, findNumbers, verify) |
arqam/explain | the grammar of the Arabic words |
arqam/units | units of measure for NumberFormat |
4. Two languages at once
toBilingual(number, code [, options]) gives {ar, en, figure}: the Arabic with «فقط … لا غير» and the tanween on the alif, as written on cheques; the English in UK style with "Only" at the end. toLanguages(number, code, languages [, options]) does the same for any languages loaded.
arqam.toBilingual("1250.50", "QAR").ararqam.toBilingual("1250.50", "QAR").enarqam.toBilingual("1250.50", "QAR").figure| Option | Values | Meaning |
|---|---|---|
only | "off" | leave out «فقط … لا غير» and "Only" |
onlyEn | "end" "start" | where "Only" goes in English (default end) |
tashkeel | as toWords | the Arabic's tashkeel (default "a": the alif) |
style | "uk" "us" | the English: uk (default) writes "and" before the tens and units |
arqam.toBilingual("1250.50", "QAR", {style: "us", onlyEn: "start"}).enarqam.toBilingual("1250.50", "QAR", {only: "off", tashkeel: "full"}).arJSON.stringify(arqam.toLanguages("99.5", "KWD", ["en", "ar"]))5. Documents: cheques, invoices, receipts, contracts
toClause(kind, number, code [, options]) writes the wording of a document around the amount: "cheque", "invoice", "receipt" or "contract" (a contract article). It gives {text, lines, words, figure}; lang: "en" writes it in English, lang: ["ar", "en"] in both ({ar, en, text}). The wording is Arqam's own, the same as the «مستندات» mode of the Arqam page; it does not claim to follow any bank's or regulator's form.
arqam.toClause("cheque", "15400.75", "QAR", {payee: "شركة الخليج للتجارة", date: "2026-11-27"}).textarqam.toClause("cheque", "15400.75", "QAR", {payee: "Gulf Trading Co.", date: "2026-11-27", lang: "en"}).text| Option | Meaning |
|---|---|
payee | who is paid (or the customer, or who paid) |
for | what the amount is for |
ref | the cheque, invoice or receipt number |
date | ISO text or a Date; written in each language |
hijri | the Hijri date beside it (the engine's Umm al-Qura calendar, the same day in every language) |
clause | the article number of a contract (default 1) |
only | «فقط … لا غير» and "Only": on, but off in a contract, where the amount sits inside a sentence |
tashkeel, style, onlyEn | as for toBilingual |
lang | "ar" (default), "en", or ["ar", "en"] |
arqam.toClause("contract", "250000", "SAR", {payee: "Al Noor Est.", for: "the supply works", clause: 5, lang: "en"}).textarqam.toClause("receipt", "750", "AED", {payee: "علي حسن", for: "إيجار شهر نوفمبر", date: "2026-11-27", hijri: true}).textarqam.toClause("invoice", "99.5", "KWD", {payee: "X", lang: ["ar", "en"]}).textThe wording is one table, arqam.toClause.wording, by language and document; arqam.toClause.kinds lists the documents. The page's «مستندات» reads its Arabic from the same table.
arqam.toClause.kindsarqam.toClause.wording.en.cheque.payee + " · " + arqam.toClause.wording.ar.cheque.payee6. Speed
The time grows in step with the length of the number: on the machine of the measurement, a number of 100 digits takes about 0.2 ms in Arabic and under 0.05 ms in English, and one of 1,000,000 digits (about 20 to 34 million characters of words) between 0.7 and 1.6 seconds in Arabic and 0.25 to 0.3 seconds in English. Every size, tashkeel and style, with the sizes of the words: the benchmark.
To measure your own machine, in the Arqam folder from GitHub: node tools/benchmark.js (every size up to 1,000,000 digits, a few minutes) or node tools/benchmark.js --quick (up to 100,000 digits). It prints the table and writes it as a page, arqam-benchmark.html, with the machine it ran on.
node tools/benchmark.js --quick node tools/benchmark.js --sizes 10,100,1000 --rounds 5 --warmup 3 --out my-benchmark.html npm run benchmark
7. Adding a language
A new language (French, German …) is a new engine and its documents; the library's code does not change.
- The engine,
arqamXX.js(XX the ISO 639-1 code in capitals), usable on its own, that givestoWords(number, {mode: "currency", currency: code, style, only})for an amount (the words of the currency's major and minor units, the decimals of Arqam's currency table), and puts itself in the table:globalThis[Symbol.for("arqam.languages")].xx = arqamXX. - Its README,
xx/README.md, and its manual,docs/arqamXX-manual.html(a page oftools/build_lang_manuals.js), and one line for the manual intools/site_header.jsand in the table of languages above. - Its documents (if it writes them): its wording in
toClause's table, with the dates in that language. - Its tests, and its module in
package.json(arqam/xx).
Then arqam(n, "xx-YY") and new arqam.NumberFormat("xx-YY") (the engine's NumberFormat), toLanguages(n, code, ["ar", "xx"]) and toClause(…, {lang: "xx"}) work with it.
8. Questions
All questions (13)
Q1Is it arqam or arqamAR?Beginner
arqam is the library; arqamAR is the name of its Arabic engine's file. Write arqam: its toWords and NumberFormat take Intl's shape, and its other calls are Arabic.
Object.getPrototypeOf(arqam) === arqamARQ2Why are the engines called arqamAR and arqamEN?Beginner
Each language is an engine named arqam with the language's two-letter ISO 639-1 code in capitals: arqamAR, arqamEN, later arqamFR … They name the files to load; the library reaches each language by its locale.
Q3How do I get English words through arqam?Beginner
Load the English engine (arqam/en as a module, or arqamEN.js as a plain script) and give an English locale. Before it is loaded an English locale is a RangeError that says so.
arqam("1250.50", "en-US", {currency: "QAR"})Q4Does loading English add a global name?Intermediate
No: a language engine puts itself in one shared table keyed by Symbol.for("arqam.languages"); a symbol key is not a global name. As plain scripts, arqamAR.js gives arqam and arqamAR, and arqamEN.js gives arqamEN.
Q5How do I write an amount in Arabic and English, as on a bilingual cheque?Beginner
arqam.toBilingual(number, code): the Arabic with «فقط … لا غير», the English with "Only", and the figure.
arqam.toBilingual("2500", "KWD").enQ6toBilingual or toLanguages?Intermediate
The same thing: toBilingual(n, code) is toLanguages(n, code, ["ar", "en"]). Use toLanguages for another set or order of languages; it gives one entry per language and the figure.
Object.keys(arqam.toLanguages("5", "QAR", ["en", "ar"])).join(", ")Q7Why is the English in UK style by default here, when arqamEN alone is in US style?Intermediate
Cheques and contracts in the Gulf and the UK write "and" before the tens and units (One Thousand Two Hundred and Fifty). style: "us" gives the US form. arqamEN on its own keeps its own default, US.
arqam.toBilingual("1250", "USD", {style: "us"}).enQ8Can Arqam write the line of a cheque, an invoice, a receipt or a contract?Beginner
Yes: toClause(kind, number, code, options), in Arabic, English or both.
arqam.toClause("cheque", "2500", "KWD", {payee: "Al Noor Est.", lang: "en"}).lines[1]Q9How do I get a document in both languages?Intermediate
lang: ["ar", "en"]: {ar, en, text}, where text is the Arabic, a blank line, then the English.
arqam.toClause("cheque", "100", "QAR", {payee: "X", lang: ["ar", "en"]}).en.lines[1]Q10Why has a contract no «فقط … لا غير»?Intermediate
In a contract the amount sits inside a sentence («… مبلغًا وقدره …، يدفعها …»), where «فقط … لا غير» does not belong; only: "on" adds them.
arqam.toClause("contract", "100", "QAR", {only: "on"}).lines[1]Q11Can I change the wording of a document?Advanced
The wording is Arqam's own, in arqam.toClause.wording (a copy: changing it changes nothing). For your own form, take words and figure from the result and write your own sentence around them.
[arqam.toClause("cheque", "15", "QAR")].map(r => "Pay " + r.figure)[0]Q12What happens if a language is not loaded?Advanced
A TypeError that says what to load.
arqam.toLanguages("5", "QAR", ["fr"])Q13How do I add a language?Advanced
An engine, its README and manual, one line in the site's menu and the table of languages, and its document wording if it writes documents: see «Adding a language».