summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/polyglossia/gloss-arabic.ldf
blob: 3d478f02757635bc612e5cca94f723d166d6ec59 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
% Language definition file (part of polyglossia v2.1 -- 2024/03/07)
%
\ProvidesFile{gloss-arabic.ldf}[polyglossia: module for Arabic]
\RequireBidi
\RequirePackage{arabicnumbers}
\RequirePackage{hijrical}

\PolyglossiaSetup{arabic}{
  bcp47=ar,
  bcp47-language=ar,
  bcp47-script=Arab,
  bcp47-region=YE,
  script=Arabic,
  direction=RL,
  langtag=ARA,
  scripttag=arab,
  hyphennames={nohyphenation},
  fontsetup=true,
  envname=Arabic,
  localnumeral=arabicnumerals
  %TODO localalph={abjad,abjad}
}

% BCP-47 compliant aliases
\setlanguagealias*{arabic}{ar}
\setlanguagealias*[locale=mashriq]{arabic}{ar-IQ}
\setlanguagealias*[locale=default]{arabic}{ar-YE}
\setlanguagealias*[locale=mashriq]{arabic}{ar-LB}
\setlanguagealias*[locale=mashriq]{arabic}{ar-JO}
\setlanguagealias*[locale=default]{arabic}{afb}
\setlanguagealias*[locale=mauritania]{arabic}{ar-MR}
\setlanguagealias*[locale=default]{arabic}{arz}
\setlanguagealias*[locale=morocco]{arabic}{ary}
\setlanguagealias*[locale=algeria]{arabic}{arq}
\setlanguagealias*[locale=tunisia]{arabic}{aeb}
\setlanguagealias*[locale=mashriq]{arabic}{ar-SY}
\setlanguagealias*[locale=libya]{arabic}{ayl}
\setlanguagealias*[locale=default]{arabic}{apd}
\setlanguagealias*[locale=mashriq]{arabic}{ar-PS}

\define@boolkey{arabic}[arabic@]{abjadalph}[true]{}

\newif\ifeastern@numerals
\define@choicekey*+{arabic}{numerals}[\xpg@val\xpg@nr]{mashriq,maghrib,eastern,western}[mashriq]{%
   \ifcase\xpg@nr\relax
      % mashriq:
      \eastern@numeralstrue%
   \or
      % maghrib:
      \eastern@numeralsfalse
   \or
      % eastern:
      \eastern@numeralstrue%
   \or
      % western:
      \eastern@numeralsfalse
   \fi
   \xpg@info{Option: Arabic, numerals=\xpg@val}%
}{\xpg@warning{Unknown Arabic numerals option `#1'}}

%this is needed for \abjad in arabicnumbers.sty
\define@boolkey{arabic}[arabic@]{abjadjimnotail}[true]{%
  \ifarabic@abjadjimnotail
    \abjad@jim@notailtrue%
  \else
    \abjad@jim@notailfalse
  \fi}

\define@choicekey*+{arabic}{locale}[\xpg@val\xpg@nr]{default,mashriq,libya,algeria,tunisia,morocco,mauritania}[default]{%
   \ifcase\xpg@nr\relax
      % default:
      \eastern@numeralstrue%
      \SetLanguageKeys{arabic}{bcp47=ar-YE,bcp47-language=ar}%
      \xpg@info{Option: arabic, locale=default}%
   \or
      % mashriq:
      \eastern@numeralstrue%
      \SetLanguageKeys{arabic}{bcp47=ar-IQ,bcp47-language=ar}%
      \xpg@info{Option: arabic, locale=mashriq}%
   \or
      % libya:
      \eastern@numeralstrue%
      \SetLanguageKeys{arabic}{bcp47=ayl,bcp47-language=ar,bcp47-region=LY}%
      \xpg@info{Option: arabic, locale=libya}%
   \or
      % algeria:
      \eastern@numeralsfalse%
      \SetLanguageKeys{arabic}{bcp47=arq,bcp47-language=ar,bcp47-region=DZ,bcp47-extension-u=nu-latn}%
      \xpg@info{Option: arabic, locale=algeria}%
   \or
      % tunisia:
      \eastern@numeralsfalse%
      \SetLanguageKeys{arabic}{bcp47=aeb,bcp47-language=ar,bcp47-region=TN,bcp47-extension-u=nu-latn}%
      \xpg@info{Option: arabic, locale=tunisia}%
   \or
      % morocco:
      \eastern@numeralsfalse%
      \SetLanguageKeys{arabic}{bcp47=ary,bcp47-language=ar,bcp47-region=MA,bcp47-extension-u=nu-latn}%
      \xpg@info{Option: arabic, locale=morocco}%
   \or
      % mauritania:
      \eastern@numeralstrue%
      \SetLanguageKeys{arabic}{bcp47=ar-MR,bcp47-language=ar,bcp47-region=MR}%
      \xpg@info{Option: arabic, locale=mauritania}%
   \fi
   \gdef\@@arabic@month{\@arabic@month{#1}}
 }{\xpg@warning{Unknown Arabic locale `#1'}}

\newif\if@hijrical
\define@choicekey*+{arabic}{calendar}[\xpg@val\xpg@nr]{gregorian,hijri,islamic}[gregorian]{%
   \ifcase\xpg@nr\relax
      % gregorian:
      \@hijricalfalse
   \or
      % hijri:
      \@hijricaltrue
   \or
      % islamic:
      \@hijricaltrue
   \fi
   \xpg@info{Option: Arabic, calendar=\xpg@val}%
}{\xpg@warning{Unknown Arabic calendar option `#1'}}


\define@key{arabic}{hijricorrection}[0]{%
  \gdef\arabic@hijri@correction{#1}}%

\newif\ifarabic@customsep\arabic@customsepfalse
\def\xpg@sepmark{}
\define@key{arabic}{sectionsep}[.]{%
   \arabic@customseptrue%
   \gdef\xpg@sepmark{#1}%
}

% Register default options
\xpg@initialize@gloss@options{arabic}{locale=default,calendar=gregorian,numerals=mashriq,hijricorrection=0,abjadjimnotail=false}
% Register alias options
\xpg@set@alias@values{arabic}{calendar}{islamic}{hijri}

\def\arabicgregmonth@default#1{\ifcase#1%
  % Egypt, Sudan, Yemen and Golf states
  \or يناير\or فبراير\or مارس\or أبريل\or مايو\or يونيو\or يوليو\or أغسطس\or سبتمبر\or أكتوبر\or نوفمبر\or ديسمبر\fi}
\def\arabicgregmonth@mashriq#1{\ifcase#1%
  % Iraq Syria Jordan Lebanon Palestine
  \or  كانون الثاني\or شباط\or آذار\or نيسان\or أيار\or حزيران\or تموز\or آب\or أيلول\or تشرين الأول\or تشرين الثاني\or كانون الأول\fi}
\def\arabicgregmonth@libya#1{\ifcase#1%
  %Lybia «تعرف في ليبيا بأسماء عربية وضعها معمر القذافي ترمز إلى فصول السنة وبعض الشخصيات التاريخية» (ar.wikipedia.org)
  \or أي النار\or النوار\or الربيع\or الطير\or الماء\or الصيف\or ناصر\or هانيبال\or الفاتح\or التمور\or الحرث\or الكانون\fi}
\def\arabicgregmonth@morocco#1{\ifcase#1%
  \or يناير\or فبراير\or مارس\or أبريل\or ماي\or يونيو\or يوليوز\or غشت\or شتنبر\or أكتوبر\or نونبر\or دجنبر\fi}
\def\arabicgregmonth@algeria#1{\ifcase#1%
  % Tunisia and Algeria
  \or جانفي\or فيفري\or مارس\or أفريل\or ماي\or جوان\or جويلية\or أوت\or سبتمبر\or أكتوبر\or نوفمبر\or ديسمبر\fi}
\let\arabicgregmonth@tunisia\arabicgregmonth@algeria
\def\arabicgregmonth@mauritania#1{\ifcase#1%
  \or يناير\or فبراير\or مارس\or إبريل\or مايو\or يونيو\or يوليو\or أغشت\or شتمبر\or أكتوبر\or نوفمبر\or دجمبر\fi}

\def\@arabic@month#1{\ifcsdef{arabicgregmonth@#1}{\expandafter\csname arabicgregmonth@#1\endcsname}%
{\xpg@warning{Option `locale=#1' is not defined for Arabic: using `default' instead}%
\arabicgregmonth@default}}

%\Hijritoday is now locale-aware and will format the date with this macro:
\DefineFormatHijriDate{arabic}{\@ensure@RTL{\arabicnumber{\value{Hijriday}}%
  \space\HijriMonthArabic{\value{Hijrimonth}}\space\arabicnumber{\value{Hijriyear}}}}

\def\captionsarabic{%
  \def\prefacename{\@ensure@RTL{مدخل}}%
  \def\refname{\@ensure@RTL{المراجع}}%
  \def\abstractname{\@ensure@RTL{ملخص}}%
  \def\bibname{\@ensure@RTL{المصادر}}%
  \def\chaptername{\@ensure@RTL{باب}}%
  \def\appendixname{\@ensure@RTL{الملاحق}}%
  \def\contentsname{\@ensure@RTL{المحتويات}}%
  %\def\contentsname{\@ensure@RTL{الفهرس}}%
  \def\listfigurename{\@ensure@RTL{قائمة الأشكال}}%
  \def\listtablename{\@ensure@RTL{قائمة الجداول}}%
  \def\indexname{\@ensure@RTL{الفهرس}}%
  \def\figurename{\@ensure@RTL{شكل}}%
  \def\tablename{\@ensure@RTL{جدول}}%
  \def\partname{\@ensure@RTL{القسم}}%
  \def\enclname{\@ensure@RTL{المرفقات}}%<-- Needs translation
  \def\ccname{\@ensure@RTL{نسخة ل‬}}% <<
  \def\headtoname{\@ensure@RTL{إلى}}%<-- Needs translation
  \def\pagename{\@ensure@RTL{صفحة}}%
  \def\seename{\@ensure@RTL{راجع}}%\alefhamza\nun\za\ra
  \def\alsoname{\@ensure@RTL{راجع أيضًا}}%<<\alefhamza\nun\za\ra
  \def\proofname{\@ensure@RTL{برهان}}%
  \def\glossaryname{\@ensure@RTL{قاموس}}%<<
}
\def\datearabic{%
 \def\today{%
  \if@hijrical%
    \Hijritoday[\arabic@hijri@correction]%
  \else%
    \if@RTL%
       \arabicnumber\day\space\@@arabic@month{\month}%
        \space\arabicnumber\year%
    \else% in LR environment we format the gregorian date within \textenglish
       \ifcsdef{english@loaded}{\textenglish{\today}}%else US format
       {\normalfontlatin\ifcase\month\or January\or February\or March\or April\or May\or June\or%
       July\or August\or September\or October\or November\or December\fi%
       \space\number\day,\space\number\year}%
    \fi%
 \fi}}

% Use \providecommand here as the ldf file might
% be reloaded via aeb (BCP).
\providecommand{\arabicnumerals}[2]{\arabicnumber{#2}}

\def\arabicnumber#1{%
  \ifeastern@numerals
    \@ensure@LTR{\arabicdigits{\number#1}}%
  \else
    \number#1%
  \fi}

\def\@ornatebracearabic#1{\RL{\char"FD3F\@arabic#1\char"FD3E}}
\def\@ornatebracealph#1{\RL{\char"FD3F\@alph#1\char"FD3E}}

\def\abjadalph#1{\expandafter\arabic@abjad@alph{\number#1}}

% This is a poor man's Arabic alphanumeric. It just uses the alphabet and
% thus ends at 28.
\def\arabic@abjad@alph#1{\ifcase#1%
   \or ا\or ب\or\abjad@three\or د\or و\or ه‍\or ز%
   \or ح\or ط\or ي\or ك\or ل\or م\or ن%
   \or س\or ع\or ف\or ص\or ق\or ر\or ش%
   \or ت\or ث\or خ\or ذ\or ض\or ظ\or غ%
   \else\xpg@ill@value{#1}{arabic@abjad@alph}\fi%
}


\def\abjadmaghribi#1{%
\ifnum#1>1999\xpg@ill@value{#1}{abjad}%
\else
  \ifnum#1<\z@\space\xpg@ill@value{#1}{abjad}%
  \else
    \ifnum#1<10\expandafter\abj@num@i\number#1%
    \else
      \ifnum#1<100\expandafter\abj@maghribi@num@ii\number#1%
      \else
        \ifnum#1<\@m\expandafter\abj@maghribi@num@iii\number#1%
        \else
          \ifnum#1<\@M\expandafter\abj@maghribi@num@iv\number#1%
          \fi
        \fi
      \fi
    \fi
  \fi
\fi
}

%maghribi س -> ص ص -> ض ش -> س ض -> ظ ظ -> غ غ -> ش
\def\abj@maghribi@num@ii#1{%
  \ifcase#1\or ي\or ك\or ل\or م\or ن%
           \or ص\or ع\or ف\or ض\fi
  \ifnum#1=\z@\abjad@zero\fi\abj@num@i}
\def\abj@maghribi@num@iii#1{%
  \ifcase#1\or ق\or ر\or س\or ت\or ث%
           \or خ\or ذ\or ظ\or غ\fi
  \ifnum#1=\z@\fi\abj@maghribi@num@ii}
\def\abj@maghribi@num@iv#1{%
  \ifcase#1\or ش\fi
  \ifnum#1=\z@\fi\abj@maghribi@num@iii}

\def\arabic@numbers{%
 \ifarabic@abjadalph
   \let\@alph\abjadalph%
   \let\@Alph\abjadalph%
 \else
   \let\@alph\abjad%
   \let\@Alph\abjad%
 \fi
}

\def\noarabic@numbers{%
  \let\@alph\latin@alph%
  \let\@Alph\latin@Alph%
}

% Store original definition
\let\xpg@save@arabic\@arabic

\def\arabic@globalnumbers{%
  \let\@arabic\arabicnumber%
  \renewcommand\thefootnote{\localnumeral*{footnote}}%
  \renewcommand\theequation{\localnumeral*{equation}}%
}

\def\noarabic@globalnumbers{%
   \let\@arabic\xpg@save@arabic%
}

\def\arabic@xetex@capsformat{%
  \let\xpg@save@sepmark\@SepMark%
  \SepMark{\xpg@sepmark}
}

\def\noarabic@xetex@capsformat{%
   \ifcsdef{xpg@save@sepmark}{%
     \SepMark{\xpg@save@sepmark}
   }{}%
}

\def\arabic@luatex@capsformat{%
  %
  % change chapter and part headings
  \ifarabic@customsep
     \ifcsdef{chapter}{%
        \let\xpg@save@thesection\thesection%
        \renewcommand*\thesection{\thechapter\xpg@sepmark\@arabic\c@section}
        \let\xpg@save@theequation\theequation%
        \renewcommand*\theequation{%
	    \ifnum \c@chapter>\z@ \thechapter\xpg@sepmark\fi\@arabic\c@equation}
        \let\xpg@save@thefigure\thefigure%
	\renewcommand*\thefigure{%
	    \ifnum\c@chapter>\z@\thechapter\xpg@sepmark\fi\@arabic\c@figure}
        \let\xpg@save@thetable\thetable%
	\renewcommand*\thetable{%
	    \ifnum\c@chapter>\z@\thechapter\xpg@sepmark\fi\@arabic\c@table}
     }{}
     \let\xpg@save@thesubsection\thesubsection%
     \renewcommand\thesubsection
	{\thesection\xpg@sepmark\@arabic\c@subsection}
     \let\xpg@save@thesubsubsection\thesubsubsection%
     \renewcommand\thesubsubsection{\thesubsection\xpg@sepmark\@arabic\c@subsubsection}
     \let\xpg@save@theparagraph\theparagraph%
     \renewcommand\theparagraph
         {\thesubsubsection\xpg@sepmark\@arabic\c@paragraph}
     \let\xpg@save@thesubparagraph\thesubparagraph%
     \renewcommand\thesubparagraph{\theparagraph\xpg@sepmark\@arabic\c@subparagraph}
  \fi% (end \ifarabic@customsep)
}

\def\noarabic@luatex@capsformat{%
   \ifcsdef{xpg@save@thesection}{%
        \let\thesection\xpg@save@thesection%
   }{}%
   \ifcsdef{xpg@save@theequation}{%
        \let\theequation\xpg@save@theequation%
   }{}%
   \ifcsdef{xpg@save@thefigure}{%
        \let\thefigure\xpg@save@thefigure%
   }{}%
   \ifcsdef{xpg@save@thetable}{%
        \let\thetable\xpg@save@thetable%
   }{}%
   \ifcsdef{xpg@save@thesubsection}{%
        \let\thesubsection\xpg@save@thesubsection%
   \ifcsdef{xpg@save@thesubsubsection}{%
        \let\thesubsubsection\xpg@save@thesubsubsection%
   }{}%
   }{}%
   \ifcsdef{xpg@save@theparagraph}{%
        \let\theparagraph\xpg@save@theparagraph%
   }{}%
   \ifcsdef{xpg@save@thesubparagraph}{%
        \let\thesubparagraph\xpg@save@thesubparagraph%
   }{}%
}

\def\blockextras@arabic{%
   \ifarabic@customsep
      \ifxetex
        \arabic@xetex@capsformat
      \else
        \arabic@luatex@capsformat
      \fi   
   \fi
}
%
\def\noextras@arabic{%
    \ifarabic@customsep
      \ifxetex
        \noarabic@xetex@capsformat
      \else
        \noarabic@luatex@capsformat
      \fi   
   \fi
}

\endinput