xref: /webtrees/app/Module/LanguageRussian.php (revision d11be7027e34e3121be11cc025421873364403f9)
1<?php
2
3/**
4 * webtrees: online genealogy
5 * Copyright (C) 2023 webtrees development team
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
18declare(strict_types=1);
19
20namespace Fisharebest\Webtrees\Module;
21
22use Fisharebest\Localization\Locale\LocaleInterface;
23use Fisharebest\Localization\Locale\LocaleRu;
24use Fisharebest\Webtrees\Encodings\UTF8;
25
26/**
27 * Class LanguageRussian.
28 */
29class LanguageRussian extends AbstractModule implements ModuleLanguageInterface
30{
31    use ModuleLanguageTrait;
32
33    /**
34     * Phone-book ordering of letters.
35     *
36     * @return array<int,string>
37     */
38    public function alphabet(): array
39    {
40        return [
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     * @return LocaleInterface
79     */
80    public function locale(): LocaleInterface
81    {
82        return new LocaleRu();
83    }
84
85
86    /**
87     * Letters with diacritics that are considered distinct letters in this language.
88     *
89     * @return array<string,string>
90     */
91    protected function normalizeExceptions(): array
92    {
93        return [
94            UTF8::CYRILLIC_CAPITAL_LETTER_IE . UTF8::COMBINING_DIAERESIS => UTF8::CYRILLIC_CAPITAL_LETTER_IO,
95            UTF8::CYRILLIC_SMALL_LETTER_IE . UTF8::COMBINING_DIAERESIS   => UTF8::CYRILLIC_SMALL_LETTER_IO,
96            UTF8::CYRILLIC_CAPITAL_LETTER_I . UTF8::COMBINING_BREVE      => UTF8::CYRILLIC_CAPITAL_LETTER_SHORT_I,
97            UTF8::CYRILLIC_SMALL_LETTER_I . UTF8::COMBINING_BREVE        => UTF8::CYRILLIC_SMALL_LETTER_SHORT_I,
98        ];
99    }
100}
101