xref: /webtrees/app/Module/LanguageUzbek.php (revision 81b514b4672980e5db010e9d89b55eaf131e798f)
1*81b514b4SGreg Roach<?php
2*81b514b4SGreg Roach
3*81b514b4SGreg Roach/**
4*81b514b4SGreg Roach * webtrees: online genealogy
5*81b514b4SGreg Roach * Copyright (C) 2023 webtrees development team
6*81b514b4SGreg Roach * This program is free software: you can redistribute it and/or modify
7*81b514b4SGreg Roach * it under the terms of the GNU General Public License as published by
8*81b514b4SGreg Roach * the Free Software Foundation, either version 3 of the License, or
9*81b514b4SGreg Roach * (at your option) any later version.
10*81b514b4SGreg Roach * This program is distributed in the hope that it will be useful,
11*81b514b4SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
12*81b514b4SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13*81b514b4SGreg Roach * GNU General Public License for more details.
14*81b514b4SGreg Roach * You should have received a copy of the GNU General Public License
15*81b514b4SGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>.
16*81b514b4SGreg Roach */
17*81b514b4SGreg Roach
18*81b514b4SGreg Roachdeclare(strict_types=1);
19*81b514b4SGreg Roach
20*81b514b4SGreg Roachnamespace Fisharebest\Webtrees\Module;
21*81b514b4SGreg Roach
22*81b514b4SGreg Roachuse Fisharebest\Localization\Locale\LocaleInterface;
23*81b514b4SGreg Roachuse Fisharebest\Localization\Locale\LocalePl;
24*81b514b4SGreg Roachuse Fisharebest\Localization\Locale\LocaleUz;
25*81b514b4SGreg Roachuse Fisharebest\Webtrees\Encodings\UTF8;
26*81b514b4SGreg Roach
27*81b514b4SGreg Roach/**
28*81b514b4SGreg Roach * Class LanguageUzbek.
29*81b514b4SGreg Roach */
30*81b514b4SGreg Roachclass LanguageUzbek extends AbstractModule implements ModuleLanguageInterface
31*81b514b4SGreg Roach{
32*81b514b4SGreg Roach    use ModuleLanguageTrait;
33*81b514b4SGreg Roach
34*81b514b4SGreg Roach    /**
35*81b514b4SGreg Roach     * Phone-book ordering of letters.
36*81b514b4SGreg Roach     *
37*81b514b4SGreg Roach     * @return array<int,string>
38*81b514b4SGreg Roach     */
39*81b514b4SGreg Roach    public function alphabet(): array
40*81b514b4SGreg Roach    {
41*81b514b4SGreg Roach        return [
42*81b514b4SGreg Roach            'A',
43*81b514b4SGreg Roach            'B',
44*81b514b4SGreg Roach            'D',
45*81b514b4SGreg Roach            'E',
46*81b514b4SGreg Roach            'F',
47*81b514b4SGreg Roach            'G',
48*81b514b4SGreg Roach            'H',
49*81b514b4SGreg Roach            'I',
50*81b514b4SGreg Roach            'J',
51*81b514b4SGreg Roach            'K',
52*81b514b4SGreg Roach            'L',
53*81b514b4SGreg Roach            'M',
54*81b514b4SGreg Roach            'N',
55*81b514b4SGreg Roach            'O',
56*81b514b4SGreg Roach            'P',
57*81b514b4SGreg Roach            'Q',
58*81b514b4SGreg Roach            'R',
59*81b514b4SGreg Roach            'S',
60*81b514b4SGreg Roach            'T',
61*81b514b4SGreg Roach            'U',
62*81b514b4SGreg Roach            'V',
63*81b514b4SGreg Roach            'X',
64*81b514b4SGreg Roach            'Y',
65*81b514b4SGreg Roach            'Z',
66*81b514b4SGreg Roach            'O' . UTF8::MODIFIER_LETTER_TURNED_COMMA,
67*81b514b4SGreg Roach            'G' . UTF8::MODIFIER_LETTER_TURNED_COMMA,
68*81b514b4SGreg Roach            'SH',
69*81b514b4SGreg Roach            'CH',
70*81b514b4SGreg Roach            'NG',
71*81b514b4SGreg Roach        ];
72*81b514b4SGreg Roach    }
73*81b514b4SGreg Roach
74*81b514b4SGreg Roach    /**
75*81b514b4SGreg Roach     * Some languages use digraphs and trigraphs.
76*81b514b4SGreg Roach     *
77*81b514b4SGreg Roach     * @param string $string
78*81b514b4SGreg Roach     *
79*81b514b4SGreg Roach     * @return string
80*81b514b4SGreg Roach     */
81*81b514b4SGreg Roach    public function initialLetter(string $string): string
82*81b514b4SGreg Roach    {
83*81b514b4SGreg Roach        if (str_starts_with($string, 'O' . UTF8::MODIFIER_LETTER_TURNED_COMMA)) {
84*81b514b4SGreg Roach            return 'O' . UTF8::MODIFIER_LETTER_TURNED_COMMA;
85*81b514b4SGreg Roach        }
86*81b514b4SGreg Roach
87*81b514b4SGreg Roach        if (str_starts_with($string, 'G' . UTF8::MODIFIER_LETTER_TURNED_COMMA)) {
88*81b514b4SGreg Roach            return 'G' . UTF8::MODIFIER_LETTER_TURNED_COMMA;
89*81b514b4SGreg Roach        }
90*81b514b4SGreg Roach
91*81b514b4SGreg Roach        if (str_starts_with($string, 'SH')) {
92*81b514b4SGreg Roach            return 'SH';
93*81b514b4SGreg Roach        }
94*81b514b4SGreg Roach
95*81b514b4SGreg Roach        if (str_starts_with($string, 'CH')) {
96*81b514b4SGreg Roach            return 'CH';
97*81b514b4SGreg Roach        }
98*81b514b4SGreg Roach
99*81b514b4SGreg Roach        if (str_starts_with($string, 'NG')) {
100*81b514b4SGreg Roach            return 'NG';
101*81b514b4SGreg Roach        }
102*81b514b4SGreg Roach
103*81b514b4SGreg Roach        return mb_substr($string, 0, 1);
104*81b514b4SGreg Roach    }
105*81b514b4SGreg Roach
106*81b514b4SGreg Roach    /**
107*81b514b4SGreg Roach     * Should this module be enabled when it is first installed?
108*81b514b4SGreg Roach     *
109*81b514b4SGreg Roach     * @return bool
110*81b514b4SGreg Roach     */
111*81b514b4SGreg Roach    public function isEnabledByDefault(): bool
112*81b514b4SGreg Roach    {
113*81b514b4SGreg Roach        return false;
114*81b514b4SGreg Roach    }
115*81b514b4SGreg Roach
116*81b514b4SGreg Roach    /**
117*81b514b4SGreg Roach     * @return LocaleInterface
118*81b514b4SGreg Roach     */
119*81b514b4SGreg Roach    public function locale(): LocaleInterface
120*81b514b4SGreg Roach    {
121*81b514b4SGreg Roach        return new LocaleUz();
122*81b514b4SGreg Roach    }
123*81b514b4SGreg Roach}
124