Issues (2559)

app/Module/LanguageSlovakian.php (1 issue)

Labels
Severity
1
<?php
2
3
/**
4
 * webtrees: online genealogy
5
 * Copyright (C) 2025 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
18
declare(strict_types=1);
19
20
namespace Fisharebest\Webtrees\Module;
21
22
use Fisharebest\Localization\Locale\LocaleInterface;
23
use Fisharebest\Localization\Locale\LocaleSk;
24
use Fisharebest\Webtrees\Relationship;
25
26
use function mb_substr;
27
use function str_repeat;
28
use function str_starts_with;
29
30
class LanguageSlovakian extends AbstractModule implements ModuleLanguageInterface
31
{
32
    use ModuleLanguageTrait;
33
34
    protected const array MALE_COUSINS = [
0 ignored issues
show
A parse error occurred: Syntax error, unexpected T_STRING, expecting '=' on line 34 at column 26
Loading history...
35
        ['', ''],
36
        ['bratranec', '%s bratranca'],
37
        ['druhostupňový bratranec', '%s druhostupňového bratranca'],
38
        ['bratranec z 3. kolena', '%s bratranca z 3. kolena'],
39
        ['bratranec zo 4. kolena', '%s bratranca zo 4. kolena'],
40
        ['bratranec z 5. kolena', '%s bratranca z 5. kolena'],
41
        ['bratranec zo 6. kolena', '%s bratranca zo 6. kolena'],
42
        ['bratranec zo 7. kolena', '%s bratranca zo 7. kolena'],
43
        ['bratranec z 8. kolena', '%s bratranca z 8. kolena'],
44
        ['bratranec z 9. kolena', '%s bratranca z 9. kolena'],
45
        ['bratranec z 10. kolena', '%s bratranca z 10. kolena'],
46
        ['bratranec z 11. kolena', '%s bratranca z 11. kolena'],
47
        ['bratranec z 12. kolena', '%s bratranca z 12. kolena'],
48
        ['bratranec z 13. kolena', '%s bratranca z 13. kolena'],
49
        ['bratranec zo 14. kolena', '%s bratranca zo 14. kolena'],
50
        ['bratranec z 15. kolena', '%s bratranca z 15. kolena'],
51
        ['bratranec zo 16. kolena', '%s bratranca zo 16. kolena'],
52
        ['bratranec zo 17. kolena', '%s bratranca zo 17. kolena'],
53
    ];
54
55
    protected const array FEMALE_COUSINS = [
56
        ['', ''],
57
        ['sesternica', '%s sesternice'],
58
        ['druhostupňová sesternica', '%s druhostupňovej sesternice'],
59
        ['sesternica z 3. kolena', '%s sesternice z 3. kolena'],
60
        ['sesternica zo 4. kolena', '%s sesternice zo 4. kolena'],
61
        ['sesternica z 5. kolena', '%s sesternice z 5. kolena'],
62
        ['sesternica zo 6. kolena', '%s sesternice zo 6. kolena'],
63
        ['sesternica zo 7. kolena', '%s sesternice zo 7. kolena'],
64
        ['sesternica z 8. kolena', '%s sesternice z 8. kolena'],
65
        ['sesternica z 9. kolena', '%s sesternice z 9. kolena'],
66
        ['sesternica z 10. kolena', '%s sesternice z 10. kolena'],
67
        ['sesternica z 11. kolena', '%s sesternice z 11. kolena'],
68
        ['sesternica z 12. kolena', '%s sesternice z 12. kolena'],
69
        ['sesternica z 13. kolena', '%s sesternice z 13. kolena'],
70
        ['sesternica zo 14. kolena', '%s sesternice zo 14. kolena'],
71
        ['sesternica z 15. kolena', '%s sesternice z 15. kolena'],
72
        ['sesternica zo 16. kolena', '%s sesternice zo 16. kolena'],
73
        ['sesternica zo 17. kolena', '%s sesternice zo 17. kolena'],
74
    ];
75
76
    /**
77
     * @return array<int,string>
78
     */
79
    public function alphabet(): array
80
    {
81
        return ['A', 'Á', 'Ä', 'B', 'C', 'Č', 'D', 'Ď', 'DZ', 'DŽ', 'E', 'É', 'F', 'G', 'H', 'CH', 'I', 'Í', 'J', 'K', 'L', 'Ľ', 'Ĺ', 'M', 'N', 'Ň', 'O', 'Ó', 'Ô', 'P', 'Q', 'R', 'Ŕ', 'S', 'Š', 'T', 'Ť', 'U', 'Ú', 'V', 'W', 'X', 'Y', 'Ý', 'Z', 'Ž'];
82
    }
83
84
    public function initialLetter(string $string): string
85
    {
86
        foreach (['CH', 'DZ', 'DŽ'] as $digraph) {
87
            if (str_starts_with($string, $digraph)) {
88
                return $digraph;
89
            }
90
        }
91
92
        return mb_substr($string, 0, 1);
93
    }
94
95
    public function locale(): LocaleInterface
96
    {
97
        return new LocaleSk();
98
    }
99
    /**
100
     * @return array<Relationship>
101
     */
102
    public function relationships(): array
103
    {
104
        $pra = static fn (int $n, string $nominative, string $genitive): array => [
105
            ($n > 3 ? 'pra ×' . $n . ' ' : str_repeat('pra-', $n)) . $nominative,
106
            ($n > 3 ? 'pra ×' . $n . ' ' : str_repeat('pra-', $n)) . $genitive,
107
        ];
108
109
        $cousin = static fn (int $n, array $cousins, string $nominative, string $genitive): array => $cousins[$n] ?? [
110
            $nominative . ' z ' . $n . '. kolena',
111
            $genitive . '%s z ' . $n . '. kolena',
112
        ];
113
114
        return [
115
            // Parents
116
            Relationship::fixed('otec', '%s otca')->father(),
117
            Relationship::fixed('matka', '%s matky')->mother(),
118
            Relationship::fixed('rodič', '%s rodiča')->parent(),
119
            // Children
120
            Relationship::fixed('syn', '%s syna')->son(),
121
            Relationship::fixed('dcéra', '%s dcéry')->daughter(),
122
            Relationship::fixed('dieťa', '%s dieťaťa')->child(),
123
            // Siblings
124
            Relationship::fixed('brat', '%s brata')->brother(),
125
            Relationship::fixed('sestra', '%s sestry')->sister(),
126
            Relationship::fixed('súrodenec', '%s súrodenca')->sibling(),
127
            // Divorced partners
128
            Relationship::fixed('exmanželka', '%s exmanželky')->divorced()->partner()->female(),
129
            Relationship::fixed('exmanžel', '%s exmanžela')->divorced()->partner()->male(),
130
            Relationship::fixed('exmanžel/manželka', '%s exmanžela/manželky')->divorced()->partner(),
131
            // Engaged partners
132
            Relationship::fixed('snúbenec', '%s snúbence')->engaged()->partner()->female(),
133
            Relationship::fixed('snúbenica', '%s snúbenice')->engaged()->partner()->male(),
134
            // Married parters
135
            Relationship::fixed('manželka', '%s manželky')->wife(),
136
            Relationship::fixed('manžel', '%s manžela')->husband(),
137
            Relationship::fixed('manžel/manželka', '%s manžela/manželky')->spouse(),
138
            Relationship::fixed('partnerka', '%s partnerky')->partner()->female(),
139
            // Unmarried partners
140
            Relationship::fixed('partner', '%s partnera')->partner(),
141
            // In-laws
142
            Relationship::fixed('tesť', '%s tesťa')->wife()->father(),
143
            Relationship::fixed('testiná', '%s testinej')->wife()->mother(),
144
            Relationship::fixed('svokor', '%s svokra')->spouse()->father(),
145
            Relationship::fixed('svokra', '%s svokry')->spouse()->mother(),
146
            Relationship::fixed('zať', '%s zaťa')->child()->husband(),
147
            Relationship::fixed('nevesta', '%s nevesty')->child()->wife(),
148
            Relationship::fixed('švagor', '%s švagra')->spouse()->brother(),
149
            Relationship::fixed('švagor', '%s švagra')->sibling()->husband(),
150
            Relationship::fixed('švagriná', '%s švagrinej')->spouse()->sister(),
151
            Relationship::fixed('švagriná', '%s švagrinej')->sibling()->wife(),
152
            // Half-siblings
153
            Relationship::fixed('nevlastný brat', '%s nevlastného brata')->parent()->son(),
154
            Relationship::fixed('nevlastná sestra', '%s nevlastnej sestry')->parent()->daughter(),
155
            Relationship::fixed('nevlastný súrodenec', '%s nevlastného súrodenca')->parent()->child(),
156
            // Grandparents
157
            Relationship::fixed('starý otec', '%s starého otca')->parent()->father(),
158
            Relationship::fixed('stará matka', '%s starej matky')->parent()->mother(),
159
            Relationship::fixed('starý rodič', '%s starého rodiča')->parent()->parent(),
160
            // Great-grandparents
161
            Relationship::fixed('prastarý otec', '%s prastarého otca')->parent()->parent()->father(),
162
            Relationship::fixed('prastarý otec', '%s prastarého otca')->parent()->parent()->mother(),
163
            Relationship::fixed('prastarý otec', '%s prastarého otca')->parent()->parent()->parent(),
164
            // Ancestors
165
            Relationship::dynamic(static fn (int $n) => $pra($n - 1, 'prastarý otec', '%s prastarého otca'))->ancestor()->male(),
166
            Relationship::dynamic(static fn (int $n) => $pra($n - 1, 'prastará matka', '%s prastarej matky'))->ancestor()->female(),
167
            Relationship::dynamic(static fn (int $n) => $pra($n - 1, 'prastarý rodič', '%s prastarého rodiča'))->ancestor(),
168
            // Grandchildren
169
            Relationship::fixed('vnuk', '%s vnuka')->child()->son(),
170
            Relationship::fixed('vnučka', '%s vnučky')->child()->daughter(),
171
            Relationship::fixed('vnúča', '%s vnúčaťa')->child()->child(),
172
            // Great-grandchildren
173
            Relationship::fixed('pravnuk', '%s pravnuka')->child()->child()->son(),
174
            Relationship::fixed('pravnučka', '%s pravnučky')->child()->child()->daughter(),
175
            Relationship::fixed('pravnúča', '%s pravnúčaťa')->child()->child()->child(),
176
            // Descendants
177
            Relationship::dynamic(static fn (int $n) => $pra($n - 1, 'pravnuk', '%s pravnuka'))->ancestor()->male(),
178
            Relationship::dynamic(static fn (int $n) => $pra($n - 1, 'pravnučka', '%s pravnučky'))->ancestor()->female(),
179
            Relationship::dynamic(static fn (int $n) => $pra($n - 1, 'pravnúča', '%s pravnúčaťa'))->ancestor(),
180
            // Aunts and uncles
181
            Relationship::fixed('ujo', '%s uja')->mother()->brother(),
182
            Relationship::fixed('ujčiná', '%s ujčinej')->mother()->brother()->wife(),
183
            Relationship::fixed('stryná', '%s strynej')->father()->brother()->wife(),
184
            Relationship::fixed('strýko', '%s strýka')->parent()->brother(),
185
            Relationship::fixed('teta', '%s tety')->parent()->sister(),
186
            // Great-aunts and great-uncles
187
            Relationship::dynamic(static fn (int $n) => $pra($n - 2, 'prastrýko', '%s prastrýka'))->ancestor()->brother(),
188
            Relationship::dynamic(static fn (int $n) => $pra($n - 2, 'prateta', '%s pratety'))->ancestor()->sister(),
189
            // Nieces and nephews
190
            Relationship::fixed('synovec', '%s synovca')->sibling()->son(),
191
            Relationship::fixed('neter', '%s netere')->sibling()->daughter(),
192
            // Great-nieces and great-nephews
193
            Relationship::fixed('prasynovec', '%s prasynovca')->sibling()->child()->son(),
194
            Relationship::fixed('praneter', '%s pranetere')->sibling()->child()->daughter(),
195
            Relationship::dynamic(static fn (int $n) => $pra($n - 2, 'prasynovec', '%s prasynovca'))->sibling()->descendant()->son(),
196
            Relationship::dynamic(static fn (int $n) => $pra($n - 2, 'praneter', '%s pranetere'))->sibling()->descendant()->daughter(),
197
            // Cousins
198
            Relationship::dynamic(static fn (int $n): array => $cousin($n, static::FEMALE_COUSINS, '', ''))->symmetricCousin()->female(),
199
            Relationship::dynamic(static fn (int $n): array => $cousin($n, static::MALE_COUSINS, '', ''))->symmetricCousin()->male(),
200
            Relationship::dynamic(static fn (int $n): array => $cousin($n, static::MALE_COUSINS, '', ''))->symmetricCousin(),
201
        ];
202
    }
203
}
204