@kirnu/arabic-core 0.1.2 → 0.2.1
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 +12 -0
- package/dist/index.cjs +27 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +27 -6
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +1 -1
- package/src/numbers/currencies.ts +57 -6
|
@@ -1,7 +1,26 @@
|
|
|
1
1
|
import { cf } from './lexicon';
|
|
2
2
|
import type { CountedNoun, Gender } from './lexicon';
|
|
3
3
|
|
|
4
|
-
export type CurrencyCode =
|
|
4
|
+
export type CurrencyCode =
|
|
5
|
+
| 'SAR'
|
|
6
|
+
| 'AED'
|
|
7
|
+
| 'EGP'
|
|
8
|
+
| 'QAR'
|
|
9
|
+
| 'KWD'
|
|
10
|
+
| 'BHD'
|
|
11
|
+
| 'OMR'
|
|
12
|
+
| 'JOD'
|
|
13
|
+
| 'USD'
|
|
14
|
+
| 'EUR'
|
|
15
|
+
| 'IQD'
|
|
16
|
+
| 'DZD'
|
|
17
|
+
| 'MAD'
|
|
18
|
+
| 'TND'
|
|
19
|
+
| 'LYD'
|
|
20
|
+
| 'YER'
|
|
21
|
+
| 'SDG'
|
|
22
|
+
| 'SYP'
|
|
23
|
+
| 'LBP';
|
|
5
24
|
|
|
6
25
|
export interface CurrencyDefinition {
|
|
7
26
|
code: CurrencyCode;
|
|
@@ -21,12 +40,20 @@ interface NounForms {
|
|
|
21
40
|
forms: [string, string, string, string, string];
|
|
22
41
|
}
|
|
23
42
|
|
|
24
|
-
|
|
25
|
-
|
|
43
|
+
type Forms = [string, string, string, string, string];
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Nisba adjective agreeing with the noun: sg, sg acc, dual, dual oblique, and the feminine singular used with
|
|
47
|
+
* non-human plurals. Masculine: سعودي → سعودياً، سعوديان، سعوديين، سعودية. Feminine (ليرة): سورية → سورية، سوريتان، سوريتين، سورية.
|
|
48
|
+
*/
|
|
49
|
+
const nisba = (adj: string, gender: Gender): Forms =>
|
|
50
|
+
gender === 'masculine'
|
|
51
|
+
? [adj, `${adj}اً`, `${adj}ان`, `${adj}ين`, `${adj}ة`]
|
|
52
|
+
: [`${adj}ة`, `${adj}ة`, `${adj}تان`, `${adj}تين`, `${adj}ة`];
|
|
26
53
|
|
|
27
54
|
function noun({ gender, forms }: NounForms, adjective?: string): CountedNoun {
|
|
28
55
|
const [sg, sgAcc, du, duObl, pl] = forms;
|
|
29
|
-
const a = adjective ? nisba(adjective) : null;
|
|
56
|
+
const a = adjective ? nisba(adjective, gender) : null;
|
|
30
57
|
const w = (n: string, i: number) => (a ? `${n} ${a[i]}` : n);
|
|
31
58
|
const one = gender === 'masculine' ? ['واحد', 'واحداً'] : ['واحدة', 'واحدة'];
|
|
32
59
|
return {
|
|
@@ -46,7 +73,16 @@ const HALALA: NounForms = { gender: 'feminine', forms: ['هللة', 'هللة',
|
|
|
46
73
|
const FILS: NounForms = { gender: 'masculine', forms: ['فلس', 'فلساً', 'فلسان', 'فلسين', 'فلوس'] };
|
|
47
74
|
const PIASTRE: NounForms = { gender: 'masculine', forms: ['قرش', 'قرشاً', 'قرشان', 'قرشين', 'قروش'] };
|
|
48
75
|
const BAISA: NounForms = { gender: 'feminine', forms: ['بيسة', 'بيسة', 'بيستان', 'بيستين', 'بيسات'] };
|
|
76
|
+
// Added 2026-11-25 (competitor scan: people search tafqeet in these currencies).
|
|
77
|
+
const DOLLAR: NounForms = { gender: 'masculine', forms: ['دولار', 'دولاراً', 'دولاران', 'دولارين', 'دولارات'] };
|
|
78
|
+
/** «يورو» ends in و, so the singular takes no tanween alif: «أحد عشر يورو». */
|
|
79
|
+
const EURO: NounForms = { gender: 'masculine', forms: ['يورو', 'يورو', 'يوروان', 'يوروين', 'يوروات'] };
|
|
80
|
+
const LIRA: NounForms = { gender: 'feminine', forms: ['ليرة', 'ليرة', 'ليرتان', 'ليرتين', 'ليرات'] };
|
|
81
|
+
const CENT: NounForms = { gender: 'masculine', forms: ['سنت', 'سنتاً', 'سنتان', 'سنتين', 'سنتات'] };
|
|
82
|
+
const CENTIME: NounForms = { gender: 'masculine', forms: ['سنتيم', 'سنتيماً', 'سنتيمان', 'سنتيمين', 'سنتيمات'] };
|
|
83
|
+
const MILLIME: NounForms = { gender: 'masculine', forms: ['مليم', 'مليماً', 'مليمان', 'مليمين', 'مليمات'] };
|
|
49
84
|
|
|
85
|
+
/** `adjective` is the masculine nisba stem (سوري); it is put in the feminine for a feminine noun. Empty = none (يورو). */
|
|
50
86
|
const def = (
|
|
51
87
|
code: CurrencyCode,
|
|
52
88
|
main: NounForms,
|
|
@@ -55,10 +91,10 @@ const def = (
|
|
|
55
91
|
decimals: 2 | 3,
|
|
56
92
|
): CurrencyDefinition => ({
|
|
57
93
|
code,
|
|
58
|
-
nameAr: `${main.forms[0]} ${adjective}
|
|
94
|
+
nameAr: adjective ? `${main.forms[0]} ${nisba(adjective, main.gender)[0]}` : main.forms[0],
|
|
59
95
|
subunitNameAr: sub.forms[0],
|
|
60
96
|
decimals,
|
|
61
|
-
main: noun(main, adjective),
|
|
97
|
+
main: noun(main, adjective || undefined),
|
|
62
98
|
sub: noun(sub),
|
|
63
99
|
});
|
|
64
100
|
|
|
@@ -70,4 +106,19 @@ export const CURRENCIES: Readonly<Record<CurrencyCode, CurrencyDefinition>> = {
|
|
|
70
106
|
KWD: def('KWD', DINAR, 'كويتي', FILS, 3),
|
|
71
107
|
BHD: def('BHD', DINAR, 'بحريني', FILS, 3),
|
|
72
108
|
OMR: def('OMR', RIYAL, 'عماني', BAISA, 3),
|
|
109
|
+
// Jordanian dinar: 1000 fils (cheques write fils, like the Kuwaiti and Bahraini dinar). Added 2026-11-18.
|
|
110
|
+
JOD: def('JOD', DINAR, 'أردني', FILS, 3),
|
|
111
|
+
USD: def('USD', DOLLAR, 'أمريكي', CENT, 2),
|
|
112
|
+
EUR: def('EUR', EURO, '', CENT, 2),
|
|
113
|
+
// Iraqi dinar: 1000 fils (fils coins are no longer used, but the unit is still legal).
|
|
114
|
+
IQD: def('IQD', DINAR, 'عراقي', FILS, 3),
|
|
115
|
+
DZD: def('DZD', DINAR, 'جزائري', CENTIME, 2),
|
|
116
|
+
MAD: def('MAD', DIRHAM, 'مغربي', CENTIME, 2),
|
|
117
|
+
TND: def('TND', DINAR, 'تونسي', MILLIME, 3),
|
|
118
|
+
// Libyan dinar: 1000 dirhams.
|
|
119
|
+
LYD: def('LYD', DINAR, 'ليبي', DIRHAM, 3),
|
|
120
|
+
YER: def('YER', RIYAL, 'يمني', FILS, 2),
|
|
121
|
+
SDG: def('SDG', POUND, 'سوداني', PIASTRE, 2),
|
|
122
|
+
SYP: def('SYP', LIRA, 'سوري', PIASTRE, 2),
|
|
123
|
+
LBP: def('LBP', LIRA, 'لبناني', PIASTRE, 2),
|
|
73
124
|
};
|