summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/polyglossia/gloss-russian.ldf
blob: 12fe3f24c967355d164d963d4415eddc5682d06c (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
\ProvidesFile{gloss-russian.ldf}[polyglossia: module for russian]

\RequirePackage{xpg-cyrillicnumbers}

\PolyglossiaSetup{russian}{
  bcp47=ru,
  script=Cyrillic,
  scripttag=cyrl,
  langtag=RUS,
  hyphennames={russian},
  hyphenmins={2,2},
  frenchspacing=true,
  indentfirst=true,
  fontsetup,
  localnumeral=russiannumerals,
  Localnumeral=Russiannumerals
}

% BCP-47 compliant aliases
\setlanguagealias*{russian}{ru}
\setlanguagealias*[spelling=modern]{russian}{ru-luna1918}
\setlanguagealias*[spelling=old]{russian}{ru-petr1708}

\newif\if@russian@modern
\define@key{russian}{spelling}[modern]{%
  \ifstrequal{#1}{old}%
    {\@russian@modernfalse\SetLanguageKeys{russian}{bcp47=ru-petr1708}}%
    {\@russian@moderntrue\SetLanguageKeys{russian}{bcp47=ru}}%
}

\def\captionsrussian{%
   \if@russian@modern\captionsrussian@modern\else\captionsrussian@old\fi%
}%

\def\daterussian{%
   \if@russian@modern\daterussian@modern\else\daterussian@old\fi%
}%

\newif\ifcyrillic@numerals
\newif\ifcyrillic@asbuk@numerals
\define@choicekey*+{russian}{numerals}[\xpg@val\xpg@nr]{arabic,cyrillic,cyrillic-trad,cyrillic-alph}[arabic]{%
   \ifcase\xpg@nr\relax
      % arabic:
      \cyrillic@numeralsfalse%
      \cyrillic@asbuk@numeralsfalse%
   \or
      % cyrillic:
      \cyrillic@numeralstrue%
      \cyrillic@asbuk@numeralsfalse%
   \or
      % cyrillic-trad:
      \cyrillic@numeralstrue%
      \cyrillic@asbuk@numeralsfalse%
   \or
      % cyrillic-alph:
      \cyrillic@numeralstrue%
      \cyrillic@asbuk@numeralstrue%
   \fi
   \xpg@info{Option: Russian, numerals=\xpg@val}%
}{\xpg@warning{Unknown Russian numerals value `#1'}}

\define@boolkey{russian}[russian@]{indentfirst}[true]{%
  \ifrussian@indentfirst
      \SetLanguageKeys{russian}{indentfirst=true}%
  \else
      \SetLanguageKeys{russian}{indentfirst=false}%
  \fi%
}

\define@boolkey{russian}[russian@]{babelshorthands}[true]{}

% Force punctuation after heading number
\define@boolkey{russian}[russian@]{forceheadingpunctuation}[true]{}


% Register default options
\xpg@initialize@gloss@options{russian}{babelshorthands=false,
                                       spelling=modern,
                                       numerals=arabic,
                                       indentfirst=true,
                                       forceheadingpunctuation=true}


\ifsystem@babelshorthands
  \setkeys{russian}{babelshorthands=true}
\else
  \setkeys{russian}{babelshorthands=false}
\fi

\ifcsundef{initiate@active@char}{%
  \input{babelsh.def}%
  \initiate@active@char{"}%
  \shorthandoff{"}%
}{}

\def\russian@shorthands{%
  \bbl@activate{"}%
  \def\language@group{russian}%
%  \declare@shorthand{russian}{"`}{„}%
%  \declare@shorthand{russian}{"'}{“}%
%  \declare@shorthand{russian}{"<}{«}%
%  \declare@shorthand{russian}{">}{»}%
  \declare@shorthand{russian}{""}{\hskip\z@skip}%
  \declare@shorthand{russian}{"~}{\textormath{\leavevmode\hbox{-}}{-}}%
  \declare@shorthand{russian}{"=}{\nobreak-\hskip\z@skip}%
  \declare@shorthand{russian}{"|}{\textormath{\nobreak\discretionary{-}{}{\kern.03em}\allowhyphens}{}}%
  \declare@shorthand{russian}{"-}{%
    \def\russian@sh@tmp{%
      \if\russian@sh@next-\expandafter\russian@sh@emdash%
      \else\expandafter\russian@sh@hyphen\fi%
    }%
    \futurelet\russian@sh@next\russian@sh@tmp}%
  \def\russian@sh@hyphen{%
    \nobreak\-\bbl@allowhyphens}%
  \def\russian@sh@emdash##1##2{\cdash-##1##2}%
  \def\cdash##1##2##3{\def\tempx@{##3}%
  \def\tempa@{-}\def\tempb@{~}\def\tempc@{*}%
   \ifx\tempx@\tempa@\@Acdash\else
    \ifx\tempx@\tempb@\@Bcdash\else
     \ifx\tempx@\tempc@\@Ccdash\else
      \errmessage{Wrong usage of cdash}\fi\fi\fi}%
  \def\@Acdash{\ifdim\lastskip>\z@\unskip\nobreak\hskip.2em\fi
    \cyrdash\hskip.2em\ignorespaces}%
  \def\@Bcdash{\leavevmode\ifdim\lastskip>\z@\unskip\fi
   \nobreak\cyrdash\penalty\exhyphenpenalty\hskip\z@skip\ignorespaces}%
  \def\@Ccdash{\leavevmode
   \nobreak\cyrdash\nobreak\hskip.35em\ignorespaces}%
  \ifx\cyrdash\undefined
    \def\cyrdash{\hbox to.8em{\textendash\hss\textendash}}%
  \fi
  \declare@shorthand{russian}{",}{\nobreak\hskip.2em\ignorespaces}%
}

\def\norussian@shorthands{%
  \@ifundefined{initiate@active@char}{}{\bbl@deactivate{"}}%
}


\def\captionsrussian@modern{%
   \def\prefacename{Предисловие}%
   \def\refname{Список литературы}%
   \def\abstractname{Аннотация}%
   \def\bibname{Литература}%
   \def\chaptername{Глава}%
   \def\appendixname{Приложение}%
   \ifcsundef{thechapter}%
     {\def\contentsname{Содержание}}%
     {\def\contentsname{Оглавление}}%
   \def\listfigurename{Список иллюстраций}%
   \def\listtablename{Список таблиц}%
   \def\indexname{Предметный указатель}%
   \def\authorname{Именной указатель}%
   \def\figurename{Рис.}%
   \def\tablename{Таблица}%
   \def\partname{Часть}%
   \def\enclname{вкл.}%
   \def\ccname{исх.}%
   \def\headtoname{вх.}%
   \def\pagename{с.}%
   \def\seename{см.}%
   \def\alsoname{см.~также}%
   \def\proofname{Доказательство}%
}
\def\daterussian@modern{%
      \def\today{\number\day%
      \space\ifcase\month\or%
      января\or
      февраля\or
      марта\or
      апреля\or
      мая\or
      июня\or
      июля\or
      августа\or
      сентября\or
      октября\or
      ноября\or
      декабря\fi%
      \space \number\year\space г.}%
}
     
\def\captionsrussian@old{%
   \def\prefacename{Предисловіе}%
   \def\refname{Примѣчанія}%
   \def\abstractname{Аннотація}%
   \def\bibname{Библіографія}%
   \def\chaptername{Глава}%
   \def\appendixname{Приложеніе}%
   \ifcsundef{thechapter}%
     {\def\contentsname{Содержаніе}}%
     {\def\contentsname{Оглавленіе}}%
   \def\listfigurename{Списокъ иллюстрацій}%
   \def\listtablename{Списокъ таблицъ}%
   \def\indexname{Предмѣтный указатель}%
   \def\authorname{Именной указатель}%
   \def\figurename{Рис.}%
   \def\tablename{Таблица}%
   \def\partname{Часть}%
   \def\enclname{вкл.}%
   \def\ccname{исх.}%
   \def\headtoname{вх.}%
   \def\pagename{с.}%
   \def\seename{см.}%
   \def\alsoname{см.~также}%
   \def\proofname{Доказательство}%
}

\def\daterussian@old{%
      \def\today{\number\day%
      \space\ifcase\month\or%
      января\or
      февраля\or
      марта\or
      апреля\or
      мая\or
      іюня\or
      іюля\or
      августа\or
      сентября\or
      октября\or
      ноября\or
      декабря\fi%
      \space \number\year\space г.}%
}

% Russian needs trailing dots in all headings
\def\xpg@save@autodot{}
\ifdef{\KOMAScript}{%
    \providecommand*\autodot{}%
    \let\xpg@save@autodot\autodot%
}

\def\russian@capsformat{%
  \ifrussian@forceheadingpunctuation%
   \ifdef{\KOMAScript}{%
      \renewcommand*\autodot{.}%
   }{%
      % The following is based on some ideas from ruscor.sty
      \def\@seccntformat##1{\csname pre##1\endcsname%
         \csname the##1\endcsname%
         \csname post##1\endcsname}%
       \def\@aftersepkern{\hspace{0.5em}}%
       \def\postchapter{.\@aftersepkern}%
       \def\postsection{.\@aftersepkern}%
       \def\postsubsection{.\@aftersepkern}%
       \def\postsubsubsection{.\@aftersepkern}%
       \def\postparagraph{.\@aftersepkern}%
       \def\postsubparagraph{.\@aftersepkern}%
       \def\prechapter{}%
       \def\presection{}%
       \def\presubsection{}%
       \def\presubsubsection{}%
       \def\preparagraph{}%
       \def\presubparagraph{}%
    }%
  \fi%
}

\def\norussian@capsformat{%
  \ifrussian@forceheadingpunctuation%
    \ifdef{\KOMAScript}{%
       \let\autodot\xpg@save@autodot%
    }{%
       \def\@seccntformat##1{\csname the##1\endcsname\quad}% = LaTeX kernel
    }%
  \fi%
}

\newcommand{\russiannumerals}[2]{\russiannumber{#2}}
\newcommand{\Russiannumerals}[2]{\Russiannumber{#2}}

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

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

\let\russiannumeral=\russiannumber
\let\Russiannumeral=\Russiannumber

\def\Asbuk#1{\expandafter\russian@asbuk@Alph\csname c@#1\endcsname}
\def\asbuk#1{\expandafter\russian@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\russian@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 Я%
   \else\xpg@ill@value{#1}{russian@asbuk@Alph}\fi%
}

\def\russian@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 я%
   \else\xpg@ill@value{#1}{russian@asbuk@alph}\fi%
}

\def\russian@numbers{%
   \let\latin@alph\@alph
   \let\latin@Alph\@Alph
   \ifcyrillic@numerals%
     \def\russian@alph##1{\expandafter\russiannumeral\expandafter{\the##1}}%
     \def\russian@Alph##1{\expandafter\Russiannumeral\expandafter{\the##1}}%
     \let\@alph\russian@alph%
     \let\@Alph\russian@Alph%
   \fi
}

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

\def\noextras@russian{%
   \norussian@capsformat%
   \ifcyrillic@numerals\norussian@numbers\fi%
   \ifrussian@babelshorthands\norussian@shorthands\fi%
}

\def\blockextras@russian{%
   \russian@capsformat%
   \ifcyrillic@numerals\russian@numbers\fi%
   \ifrussian@babelshorthands\russian@shorthands\fi%
}

\def\inlineextras@russian{%
   \ifrussian@babelshorthands\russian@shorthands\fi%
}

%%% These lines taken from russianb.ldf, part of babel package.
% make it optional?
\def\sh    {\mathop{\operator@font sh}\nolimits}
\def\ch    {\mathop{\operator@font ch}\nolimits}
\def\tg    {\mathop{\operator@font tg}\nolimits}
\def\arctg {\mathop{\operator@font arctg}\nolimits}
\def\arcctg{\mathop{\operator@font arcctg}\nolimits}
\def\th    {\mathop{\operator@font th}\nolimits}
\def\ctg   {\mathop{\operator@font ctg}\nolimits}
\def\cth   {\mathop{\operator@font cth}\nolimits}
\def\cosec {\mathop{\operator@font cosec}\nolimits}
\def\Prob  {\mathop{\kern\z@\mathsf{P}}\nolimits}
\def\Variance{\mathop{\kern\z@\mathsf{D}}\nolimits}
\def\nod   {\mathop{\mathrm{н.о.д.}}\nolimits}
\def\nok   {\mathop{\mathrm{н.о.к.}}\nolimits}
\def\NOD   {\mathop{\mathrm{НОД}}\nolimits}
\def\NOK   {\mathop{\mathrm{НОК}}\nolimits}
\def\Proj  {\mathop{\mathrm{Пр}}\nolimits}
%\DeclareRobustCommand{\No}{№}

\endinput