xref: /webtrees/app/Module/LanguageUzbek.php (revision 1270d2767576ed4a83917769b0ee3613e3b010bf)
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\LocalePl;
24use Fisharebest\Localization\Locale\LocaleUz;
25use Fisharebest\Webtrees\Encodings\UTF8;
26
27/**
28 * Class LanguageUzbek.
29 */
30class LanguageUzbek extends AbstractModule implements ModuleLanguageInterface
31{
32    use ModuleLanguageTrait;
33
34    /**
35     * Phone-book ordering of letters.
36     *
37     * @return array<int,string>
38     */
39    public function alphabet(): array
40    {
41        return [
42            'A',
43            'B',
44            'D',
45            'E',
46            'F',
47            'G',
48            'H',
49            'I',
50            'J',
51            'K',
52            'L',
53            'M',
54            'N',
55            'O',
56            'P',
57            'Q',
58            'R',
59            'S',
60            'T',
61            'U',
62            'V',
63            'X',
64            'Y',
65            'Z',
66            'O' . UTF8::MODIFIER_LETTER_TURNED_COMMA,
67            'G' . UTF8::MODIFIER_LETTER_TURNED_COMMA,
68            'SH',
69            'CH',
70            'NG',
71        ];
72    }
73
74    /**
75     * Some languages use digraphs and trigraphs.
76     *
77     * @param string $string
78     *
79     * @return string
80     */
81    public function initialLetter(string $string): string
82    {
83        if (str_starts_with($string, 'O' . UTF8::MODIFIER_LETTER_TURNED_COMMA)) {
84            return 'O' . UTF8::MODIFIER_LETTER_TURNED_COMMA;
85        }
86
87        if (str_starts_with($string, 'G' . UTF8::MODIFIER_LETTER_TURNED_COMMA)) {
88            return 'G' . UTF8::MODIFIER_LETTER_TURNED_COMMA;
89        }
90
91        if (str_starts_with($string, 'SH')) {
92            return 'SH';
93        }
94
95        if (str_starts_with($string, 'CH')) {
96            return 'CH';
97        }
98
99        if (str_starts_with($string, 'NG')) {
100            return 'NG';
101        }
102
103        return mb_substr($string, 0, 1);
104    }
105
106    /**
107     * Should this module be enabled when it is first installed?
108     *
109     * @return bool
110     */
111    public function isEnabledByDefault(): bool
112    {
113        return false;
114    }
115
116    /**
117     * @return LocaleInterface
118     */
119    public function locale(): LocaleInterface
120    {
121        return new LocaleUz();
122    }
123}
124