arabicfmt
Version:
Arabic-first formatting for numbers, currency, dates and bidirectional text across all 22 Arab League countries — with correct handling of the 2025–2026 Unicode currency-symbol transition (Saudi Riyal U+20C1, UAE Dirham U+20C3, Omani Rial U+20C4).
33 lines (31 loc) • 1.54 kB
TypeScript
/**
* Counted-noun agreement (العدد والمعدود) — the rule that decides whether a
* noun appears as singular, dual, plural or accusative-singular after a number.
*
* This is the shared engine behind both the currency speller (التفقيط) and the
* duration formatter: give it a count and the four inflected forms of a noun,
* and it returns the number-in-words followed by the correctly-inflected noun.
*/
/** The four inflected forms a noun needs to agree with any Arabic number. */
interface CountedNoun {
/** Grammatical gender — drives number agreement (3–9 use gender polarity). */
gender: "male" | "female";
/** Singular (مفرد): ريال / ساعة. Used for 1 and for hundreds/thousands. */
singular: string;
/** Dual (مثنى): ريالان / ساعتان. Used for exactly 2. */
dual: string;
/** Plural (جمع): ريالات / ساعات. Used for 3–10. */
plural: string;
/** Accusative singular (تمييز منصوب): ريالاً / ساعةً. Used for 11–99. */
accusative: string;
}
/**
* Spell `<number-in-words> <correctly-inflected-noun>` for a positive count.
*
* @example countedNoun(2, hourForms) // "ساعتان"
* @example countedNoun(3, hourForms) // "ثلاث ساعات"
* @example countedNoun(11, riyalForms) // "أحد عشر ريالاً"
* @example countedNoun(100, riyalForms)// "مئة ريال"
*/
declare function countedNoun(n: number, noun: CountedNoun): string;
export { type CountedNoun as C, countedNoun as c };