summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/polyglossia/gloss-serbian.ldf
blob: 3bc4740ebb487ebba2b96d0cd4b59f4dc71250aa (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
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
% Language definition file (part of polyglossia v2.2 -- 2024/07/15)
%
\ProvidesFile{gloss-serbian.ldf}[polyglossia: module for Serbian]
%TODO split into gloss-serbiancyr.ldf and gloss-serbianlat.ldf
%% load these automatically from polyglossia.sty according to the script option ??
%% same thing for all languages that have a "script" key !
%% BETTER APPROACH: see gloss-sanskrit!

\RequirePackage{xpg-cyrillicnumbers}

\PolyglossiaSetup{serbian}{
  bcp47=sr-Latn,
  bcp47-language=sr,
  bcp47-variant=ekavsk,
  bcp47-script=Latn,
  bcp47-casing=sr-Latn,
  langtag=SRB,
  hyphennames={serbian},
  hyphenmins={2,2},
  frenchspacing=true, % Правопис српскога језика, Матица српска, 2010. (измењено и допуњено, четврто издање): т. 188, под Обликовање ступца и пасуса
  indentfirst=true, % Правопис српскога језика, Матица српска, 2010. (измењено и допуњено, четврто издање): т. 188, под Обликовање ступца и пасуса
  fontsetup=false,
  localnumeral=serbiannumerals,
  Localnumeral=Serbiannumerals,
  babelname=serbian
  %TODO localalph
}

% BCP-47 compliant aliases
\setlanguagealias*{serbian}{sr}
\setlanguagealias*[script=cyrillic]{serbian}{sr-Cyrl}
\setlanguagealias*[script=latin]{serbian}{sr-Latn}

% Babel aliases
\setlanguagealias[script=cyrillic]{serbian}{serbianc}

\ifluatex
  \RequirePackage{luavlna}
\fi

\newif\if@serbian@cyr
\newif\if@serbian@ijekavian

\newif\ifcyrillic@numerals
\newif\ifcyrillic@asbuk@numerals

\def\serbian@set@languagekeys{%
   \if@serbian@cyr
     \if@serbian@ijekavian
        \SetLanguageKeys{serbian}{scripttag=cyrl,script=Cyrillic,babelname=serbianc,bcp47=sr-Cyrl-ijekavsk,bcp47-language=sr,bcp47-script=Cyrl,bcp47-variant=ijekavsk,bcp47-casing=sr-Cyrl}
     \else
        \SetLanguageKeys{serbian}{scripttag=cyrl,script=Cyrillic,babelname=serbianc,bcp47=sr-Cyrl,bcp47-language=sr,bcp47-script=Cyrl,bcp47-variant=ekavsk,bcp47-casing=sr-Cyrl}
     \fi
   \else
     \if@serbian@ijekavian
       \SetLanguageKeys{serbian}{scripttag=latn,script=Latin,babelname=serbian,bcp47=sr-Latn-ijekavsk,bcp47-language=sr,bcp47-script=Latn,bcp47-variant=ijekavsk,bcp47-casing=sr-Latn}
     \else
       \SetLanguageKeys{serbian}{scripttag=latn,script=Latin,babelname=serbian,bcp47=sr-Latn,bcp47-language=sr,bcp47-script=Latn,bcp47-variant=ekavsk,bcp47-casing=sr-Latn}
     \fi
   \fi%
}

\DeclareKeys[polyglossia/gloss/serbian]
  {
    splithyphens.if = serbian@splithyphens,
    splithyphens.default:n = true,
    datei.if = serbian@datei,
    datei.default:n = true,
    variant.choice:,
    variant / ekavian.code =
      {%
        \@serbian@ijekavianfalse
        \serbian@set@languagekeys
      },
    variant / ijekavian.code =
      {%
        \@serbian@ijekaviantrue
        \serbian@set@languagekeys
      },
    variant.default:n = ekavian,
    variant/unknown.code = \xpg@warning{Unknown Serbian variant `#1'},
    script.choice:,
    script / cyrillic.code =
      {%
        \@serbian@cyrtrue
        \SetupNonLatinPolyglossiaFont{serbian}%
        \serbian@set@languagekeys
      },
    script / latin.code =
      {%
        \@serbian@cyrfalse
        \SetupLatinPolyglossiaFont{serbian}%
          %TODO \def\serbian@language{\language=\l@serbianlat}%
          % or should we use Croatian patterns as a fallback for the time being???
        \serbian@set@languagekeys
      },
    script.default:n = cyrillic,
    script/unknown.code = \xpg@warning{Unknown Serbian script `#1'},
    numerals.choice:,
    numerals / arabic.code =
      {%
        \cyrillic@numeralsfalse
        \cyrillic@asbuk@numeralsfalse
        \SetLanguageKeys{serbian}{bcp47-extension-u=nu-latn}%
      },
    numerals / cyrillic.code =
      {%
        \cyrillic@numeralstrue
        \cyrillic@asbuk@numeralsfalse
        \SetLanguageKeys{serbian}{bcp47-extension-u=nu-cyrl}%
      },
    numerals / cyrillic-trad.code =
      {%
        \cyrillic@numeralstrue
        \cyrillic@asbuk@numeralsfalse
        \SetLanguageKeys{serbian}{bcp47-extension-u=nu-cyrl}%
      },
    numerals / cyrillic-alph.code =
      {%
        \cyrillic@numeralstrue
        \cyrillic@asbuk@numeralstrue
        \SetLanguageKeys{serbian}{bcp47-extension-u=nu-cyrl}%
      },
    numerals.default:n = arabic,
    numerals/unknown.code = \xpg@warning{Unknown Serbian numerals value `#1'}
  }

\SetGlossOptions{serbian}{script,numerals}

% Register default options
\InitializeGlossOptions{serbian}{script=cyrillic,numerals=arabic,splithyphens=true}

\def\captionsserbian{%
   \if@serbian@cyr\captionsserbian@cyr\else\captionsserbian@lat\fi
}

\def\dateserbian{%
   \if@serbian@cyr\dateserbian@cyr\else\dateserbian@lat\fi
}

\def\captionsserbian@lat{%
   \def\refname{Bibliografija}%
   \def\abstractname{Sažetak}%
   \def\bibname{Literatura}%
   \def\prefacename{Predgovor}%
   \def\chaptername{Glava}%
   \def\appendixname{Dodatak}%
   \def\contentsname{Sadržaj}%
   \def\listfigurename{Spisak slika}%
   \def\listtablename{Spisak tabela}%
   \def\indexname{Registar}%
   \def\figurename{Slika}%
   \def\tablename{Tabela}%
   \def\partname{Deo}%
   \renewcommand\thepart{\ifcase\value{part}\or Prvi\or Drugi\or
      Treći\or Četvrti\or Peti\or Šesti\or Sedmi\or Osmi\or
      Deveti\or Deseti\or Jedanaesti\or Dvanaesti\or Trinaesti\or
      Četrnaesti\or Petnaesti\or Šesnaesti\or Sedamnaesti\or
      Osamnaesti\or Devetnaesti\or Dvadeseti\fi}%
   \def\pagename{Strana}%
   \def\seename{Vidi}%
   \def\alsoname{Vidi takođe}%
   \def\enclname{Prilozi}%
   \def\ccname{Kopije}%
   \def\headtoname{Prima}%
   \def\proofname{Dokaz}%
   \def\glossaryname{Rečnik nepoznatih reči}%
   \if@serbian@ijekavian%
     \def\partname{Dio}%
     \def\glossaryname{Rječnik nepoznatih riječi}%
   \fi
}

\def\month@serbian@lat{%
  \ifcase\month\or
    januar\or
    februar\or
    mart\or
    april\or
    maj\or
    \ifserbian@datei juni\else jun\fi\or
    \ifserbian@datei juli\else jul\fi\or
    avgust\or
    septembar\or
    oktobar\or
    novembar\or
    decembar%
  \fi%
}%

\def\month@serbian@lat@gen{%
  \ifcase\month\or
    januara\or
    februara\or
    marta\or
    aprila\or
    maja\or
    juna\or
    jula\or
    avgusta\or
    septembra\or
    oktobra\or
    novembra\or
    decembra%
  \fi%
}%

\def\dateserbian@lat{%  
    \def\today{\number\day.~\month@serbian@lat\ \number\year\@ifstar{}{.}}%
    \def\todayRoman{\number\day.~\@Roman\month~\number\year\@ifstar{}{.}}%
    \def\todayGen{\number\day.~\month@serbian@lat@gen\ \number\year\@ifstar{}{.}}%
    \def\todayArabic{\number\day.~\number\month.~\number\year\@ifstar{}{.}}%
}

\def\captionsserbian@cyr{%
   \def\refname{Библиографија}%
   \def\abstractname{Сажетак}%
   \def\bibname{Литература}%
   \def\prefacename{Предговор}%
   \def\chaptername{Глава}%
   \def\appendixname{Додатак}%
   \def\contentsname{Садржај}%
   \def\listfigurename{Списак слика}%
   \def\listtablename{Списак табела}%
   \def\indexname{Регистар}%
   \def\figurename{Слика}%
   \def\tablename{Табела}%
   \def\partname{Део}%
   \renewcommand\thepart{\ifcase\value{part}\or Први\or Други\or Трећи\or
   Четврти\or Пети\or Шести\or Седми\or Осми\or Девети\or Десети\or
   Једанаести\or Дванаести\or Тринаести\or Четрнаести\or Петнаести\or
   Шеснаести\or Седамнаести\or Осамнаести\or Деветнаести\or Двадесети\fi}%
   \def\pagename{Страна}%
   \def\seename{Види}%
   \def\alsoname{Види такође}%
   \def\enclname{Прилози}%
   \def\ccname{Копије}%
   \def\headtoname{Прима}%
   \def\proofname{Доказ}%
   \def\glossaryname{Речник непознатих речи}%
   \if@serbian@ijekavian%
     \def\partname{Дио}%
     \def\glossaryname{Рјечник непознатих ријечи}%
   \fi
}

\def\month@serbian@cyr{%
  \ifcase\month\or
    јануар\or
    фебруар\or
    март\or
    април\or
    мај\or
    \ifserbian@datei јуни\else јун\fi\or
    \ifserbian@datei јули\else јул\fi\or
    август\or
    септембар\or
    октобар\or
    новембар\or
    децембар%
  \fi%
}%

\def\month@serbian@cyr@gen{%
  \ifcase\month\or
    јануара\or
    фебруара\or
    марта\or
    априла\or
    маја\or
    јуна\or
    јула\or
    августа\or
    септембра\or
    октобра\or
    новембра\or
    децембра%
  \fi%
}%

\def\dateserbian@cyr{%  
    \def\today{\number\day.~\month@serbian@cyr\ \number\year\@ifstar{}{.}}%
    \def\todayRoman{\number\day.~\@Roman\month~\number\year\@ifstar{}{.}}%
    \def\todayGen{\number\day.~\month@serbian@cyr@gen\ \number\year\@ifstar{}{.}}%
    \def\todayArabic{\number\day.~\number\month.~\number\year\@ifstar{}{.}}%
}

% Use \providecommand here as the ldf file might
% be reloaded via serbianc.
\providecommand{\serbiannumerals}[2]{\serbiannumber{#2}}
\providecommand{\Serbiannumerals}[2]{\Serbiannumber{#2}}

\def\serbiannumber#1{%
  \ifcyrillic@numerals
    \ifcyrillic@asbuk@numerals
      \serbian@asbuk@alph{#1}%
    \else
      \cyr@alph{#1}%
    \fi
  \else
    \number#1%
  \fi%
}

\def\Serbiannumber#1{%
  \ifcyrillic@numerals
    \ifcyrillic@asbuk@numerals
      \serbian@asbuk@Alph{#1}%
    \else
      \cyr@Alph{#1}%
    \fi
  \else
    \number#1%
  \fi%
}

\let\serbiannumeral=\serbiannumber
\let\Serbiannumeral=\Serbiannumber

\def\serbian@numbers{%
   \let\latin@alph\@alph
   \let\latin@Alph\@Alph
   \ifcyrillic@numerals
     \def\serbian@alph##1{\expandafter\serbiannumeral\expandafter{\the##1}}%
     \def\serbian@Alph##1{\expandafter\Serbiannumeral\expandafter{\the##1}}%
      \let\@alph\serbian@alph%
      \let\@Alph\serbian@Alph%
   \fi
}

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

\let\xpg@hyphen@char-
\def\serbian@@splhyphen#1{%
  \def\serbian@sh@tmp{%
       \ifx\serbian@sh@next\xpg@hyphen@charx#1%
       \else\expandafter\serbian@@@splhyphen{#1}\fi%
     }%
     \futurelet\serbian@sh@next\serbian@sh@tmp%
}

\def\serbian@@@splhyphen#1{%
  \ifnum\hyphenchar \font>0%
    \kern\z@\discretionary{-}{\char\hyphenchar\the\font}{#1}%
    \nobreak\hskip\z@%
  \else%
    #1%
  \fi%
}

\def\serbian@splhyphen{%
  \serbian@@splhyphen{-}%
}

\ifxetex
  % splithyphens
  \newXeTeXintercharclass\serbian@hyphen % -
  \newXeTeXintercharclass\serbian@nonsyllabicpreposition%
\fi

\def\serbian@hyphens{%
    \ifluatex
      \AfterPreamble{\enablesplithyphens{serbian}}%
    \else
      \XeTeXinterchartokenstate=1
      \XeTeXcharclass `\- \serbian@hyphen
      \XeTeXinterchartoks \z@ \serbian@hyphen = {\serbian@@splhyphen}% "-" -> "\serbian@@splhyphen-"
      % necessary if used together with vlna:
      \XeTeXinterchartoks \serbian@nonsyllabicpreposition \serbian@hyphen = {\serbian@@splhyphen}% "-" -> "\serbian@@splhyphen-"
    \fi%
}

\def\noserbian@hyphens{%
    \ifluatex
      \AfterPreamble{\disablesplithyphens{serbian}}%
    \else
      \XeTeXcharclass `\- \z@
    \fi%
}

\def\blockextras@serbian{%
  \ifcyrillic@numerals\serbian@numbers\else\noserbian@numbers\fi%
  \ifserbian@splithyphens\serbian@hyphens\else\noserbian@hyphens\fi%
}

\def\inlineextras@serbian{%
  \ifserbian@splithyphens\serbian@hyphens\else\noserbian@hyphens\fi%
}
 
\def\noextras@serbian{%
   \ifcyrillic@numerals\noserbian@numbers\fi%
   \noserbian@hyphens%
}

\def\Asbuk#1{\expandafter\serbian@asbuk@Alph\csname c@#1\endcsname}
\def\asbuk#1{\expandafter\serbian@asbuk@alph\csname c@#1\endcsname}

\def\AsbukTrad#1{\expandafter\cyr@Alph\csname c@#1\endcsname}
\def\asbukTrad#1{\expandafter\cyr@alph\csname c@#1\endcsname}

% This is a poor man's cyrillic alphanumeric.
% It just uses the alphabet and thus ends at 30.
\def\serbian@asbuk@Alph#1{\ifcase#1\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
   Ф\or Х\or Ц\or Ч\or Џ\or Ш%
   \else\xpg@ill@value{#1}{serbian@asbuk@Alph}\fi%
}

\def\serbian@asbuk@alph#1{\ifcase#1\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
   ф\or х\or ц\or ч\or џ\or ш%
   \else\xpg@ill@value{#1}{serbian@asbuk@alph}\fi%
}

 
\endinput

% TODO ? stuff from babel
% If you implement this, add an option mathfunction as in gloss-russian.ldf

\def\sh{\mathop{\operator@font sh}\nolimits} % same as \sinh
\def\ch{\mathop{\operator@font ch}\nolimits} % same as \cosh
\def\th{\mathop{\operator@font th}\nolimits} % same as \tanh
\def\cth{\mathop{\operator@font cth}\nolimits} % same as \coth
\def\arsh{\mathop{\operator@font arsh}\nolimits}
\def\arch{\mathop{\operator@font arch}\nolimits}
\def\arth{\mathop{\operator@font arth}\nolimits}
\def\arcth{\mathop{\operator@font arcth}\nolimits}
\def\tg{\mathop{\operator@font tg}\nolimits} % same as \tan
\def\ctg{\mathop{\operator@font ctg}\nolimits} % same as \cot
\def\arctg{\mathop{\operator@font arctg}\nolimits} % same as \arctan
\def\arcctg{\mathop{\operator@font arcctg}\nolimits}
\def\Prob{\mathop{\mathsf P\hskip0pt}\nolimits}
\def\Expect{\mathop{\mathsf E\hskip0pt}\nolimits}
\def\Variance{\mathop{\mathsf D\hskip0pt}\nolimits}