summaryrefslogtreecommitdiff
path: root/app/Module/LanguageSlovakian.php
blob: 58709d979f2b3d8c40f7b4a9d745a9f8181c4814 (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
<?php

/**
 * webtrees: online genealogy
 * Copyright (C) 2026 webtrees development team
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
 */

declare(strict_types=1);

namespace Fisharebest\Webtrees\Module;

use Fisharebest\Localization\Locale\LocaleInterface;
use Fisharebest\Localization\Locale\LocaleSk;
use Fisharebest\Webtrees\Relationship;

use function mb_substr;
use function str_repeat;
use function str_starts_with;

class LanguageSlovakian extends AbstractModule implements ModuleLanguageInterface
{
    use ModuleLanguageTrait;

    protected const array MALE_COUSINS = [
        ['', ''],
        ['bratranec', '%s bratranca'],
        ['druhostupňový bratranec', '%s druhostupňového bratranca'],
        ['bratranec z 3. kolena', '%s bratranca z 3. kolena'],
        ['bratranec zo 4. kolena', '%s bratranca zo 4. kolena'],
        ['bratranec z 5. kolena', '%s bratranca z 5. kolena'],
        ['bratranec zo 6. kolena', '%s bratranca zo 6. kolena'],
        ['bratranec zo 7. kolena', '%s bratranca zo 7. kolena'],
        ['bratranec z 8. kolena', '%s bratranca z 8. kolena'],
        ['bratranec z 9. kolena', '%s bratranca z 9. kolena'],
        ['bratranec z 10. kolena', '%s bratranca z 10. kolena'],
        ['bratranec z 11. kolena', '%s bratranca z 11. kolena'],
        ['bratranec z 12. kolena', '%s bratranca z 12. kolena'],
        ['bratranec z 13. kolena', '%s bratranca z 13. kolena'],
        ['bratranec zo 14. kolena', '%s bratranca zo 14. kolena'],
        ['bratranec z 15. kolena', '%s bratranca z 15. kolena'],
        ['bratranec zo 16. kolena', '%s bratranca zo 16. kolena'],
        ['bratranec zo 17. kolena', '%s bratranca zo 17. kolena'],
    ];

    protected const array FEMALE_COUSINS = [
        ['', ''],
        ['sesternica', '%s sesternice'],
        ['druhostupňová sesternica', '%s druhostupňovej sesternice'],
        ['sesternica z 3. kolena', '%s sesternice z 3. kolena'],
        ['sesternica zo 4. kolena', '%s sesternice zo 4. kolena'],
        ['sesternica z 5. kolena', '%s sesternice z 5. kolena'],
        ['sesternica zo 6. kolena', '%s sesternice zo 6. kolena'],
        ['sesternica zo 7. kolena', '%s sesternice zo 7. kolena'],
        ['sesternica z 8. kolena', '%s sesternice z 8. kolena'],
        ['sesternica z 9. kolena', '%s sesternice z 9. kolena'],
        ['sesternica z 10. kolena', '%s sesternice z 10. kolena'],
        ['sesternica z 11. kolena', '%s sesternice z 11. kolena'],
        ['sesternica z 12. kolena', '%s sesternice z 12. kolena'],
        ['sesternica z 13. kolena', '%s sesternice z 13. kolena'],
        ['sesternica zo 14. kolena', '%s sesternice zo 14. kolena'],
        ['sesternica z 15. kolena', '%s sesternice z 15. kolena'],
        ['sesternica zo 16. kolena', '%s sesternice zo 16. kolena'],
        ['sesternica zo 17. kolena', '%s sesternice zo 17. kolena'],
    ];

    /**
     * @return array<int,string>
     */
    public function alphabet(): array
    {
        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', 'Ž'];
    }

    public function initialLetter(string $string): string
    {
        foreach (['CH', 'DZ', 'DŽ'] as $digraph) {
            if (str_starts_with($string, $digraph)) {
                return $digraph;
            }
        }

        return mb_substr($string, 0, 1);
    }

    public function locale(): LocaleInterface
    {
        return new LocaleSk();
    }
    /**
     * @return array<Relationship>
     */
    public function relationships(): array
    {
        $pra = static fn (int $n, string $nominative, string $genitive): array => [
            ($n > 3 ? 'pra ×' . $n . ' ' : str_repeat('pra-', $n)) . $nominative,
            ($n > 3 ? 'pra ×' . $n . ' ' : str_repeat('pra-', $n)) . $genitive,
        ];

        $cousin = static fn (int $n, array $cousins, string $nominative, string $genitive): array => $cousins[$n] ?? [
            $nominative . ' z ' . $n . '. kolena',
            $genitive . '%s z ' . $n . '. kolena',
        ];

        return [
            // Parents
            Relationship::fixed('otec', '%s otca')->father(),
            Relationship::fixed('matka', '%s matky')->mother(),
            Relationship::fixed('rodič', '%s rodiča')->parent(),
            // Children
            Relationship::fixed('syn', '%s syna')->son(),
            Relationship::fixed('dcéra', '%s dcéry')->daughter(),
            Relationship::fixed('dieťa', '%s dieťaťa')->child(),
            // Siblings
            Relationship::fixed('brat', '%s brata')->brother(),
            Relationship::fixed('sestra', '%s sestry')->sister(),
            Relationship::fixed('súrodenec', '%s súrodenca')->sibling(),
            // Divorced partners
            Relationship::fixed('exmanželka', '%s exmanželky')->divorced()->partner()->female(),
            Relationship::fixed('exmanžel', '%s exmanžela')->divorced()->partner()->male(),
            Relationship::fixed('exmanžel/manželka', '%s exmanžela/manželky')->divorced()->partner(),
            // Engaged partners
            Relationship::fixed('snúbenec', '%s snúbence')->engaged()->partner()->female(),
            Relationship::fixed('snúbenica', '%s snúbenice')->engaged()->partner()->male(),
            // Married parters
            Relationship::fixed('manželka', '%s manželky')->wife(),
            Relationship::fixed('manžel', '%s manžela')->husband(),
            Relationship::fixed('manžel/manželka', '%s manžela/manželky')->spouse(),
            Relationship::fixed('partnerka', '%s partnerky')->partner()->female(),
            // Unmarried partners
            Relationship::fixed('partner', '%s partnera')->partner(),
            // In-laws
            Relationship::fixed('tesť', '%s tesťa')->wife()->father(),
            Relationship::fixed('testiná', '%s testinej')->wife()->mother(),
            Relationship::fixed('svokor', '%s svokra')->spouse()->father(),
            Relationship::fixed('svokra', '%s svokry')->spouse()->mother(),
            Relationship::fixed('zať', '%s zaťa')->child()->husband(),
            Relationship::fixed('nevesta', '%s nevesty')->child()->wife(),
            Relationship::fixed('švagor', '%s švagra')->spouse()->brother(),
            Relationship::fixed('švagor', '%s švagra')->sibling()->husband(),
            Relationship::fixed('švagriná', '%s švagrinej')->spouse()->sister(),
            Relationship::fixed('švagriná', '%s švagrinej')->sibling()->wife(),
            // Half-siblings
            Relationship::fixed('nevlastný brat', '%s nevlastného brata')->parent()->son(),
            Relationship::fixed('nevlastná sestra', '%s nevlastnej sestry')->parent()->daughter(),
            Relationship::fixed('nevlastný súrodenec', '%s nevlastného súrodenca')->parent()->child(),
            // Grandparents
            Relationship::fixed('starý otec', '%s starého otca')->parent()->father(),
            Relationship::fixed('stará matka', '%s starej matky')->parent()->mother(),
            Relationship::fixed('starý rodič', '%s starého rodiča')->parent()->parent(),
            // Great-grandparents
            Relationship::fixed('prastarý otec', '%s prastarého otca')->parent()->parent()->father(),
            Relationship::fixed('prastarý otec', '%s prastarého otca')->parent()->parent()->mother(),
            Relationship::fixed('prastarý otec', '%s prastarého otca')->parent()->parent()->parent(),
            // Ancestors
            Relationship::dynamic(static fn (int $n) => $pra($n - 1, 'prastarý otec', '%s prastarého otca'))->ancestor()->male(),
            Relationship::dynamic(static fn (int $n) => $pra($n - 1, 'prastará matka', '%s prastarej matky'))->ancestor()->female(),
            Relationship::dynamic(static fn (int $n) => $pra($n - 1, 'prastarý rodič', '%s prastarého rodiča'))->ancestor(),
            // Grandchildren
            Relationship::fixed('vnuk', '%s vnuka')->child()->son(),
            Relationship::fixed('vnučka', '%s vnučky')->child()->daughter(),
            Relationship::fixed('vnúča', '%s vnúčaťa')->child()->child(),
            // Great-grandchildren
            Relationship::fixed('pravnuk', '%s pravnuka')->child()->child()->son(),
            Relationship::fixed('pravnučka', '%s pravnučky')->child()->child()->daughter(),
            Relationship::fixed('pravnúča', '%s pravnúčaťa')->child()->child()->child(),
            // Descendants
            Relationship::dynamic(static fn (int $n) => $pra($n - 1, 'pravnuk', '%s pravnuka'))->ancestor()->male(),
            Relationship::dynamic(static fn (int $n) => $pra($n - 1, 'pravnučka', '%s pravnučky'))->ancestor()->female(),
            Relationship::dynamic(static fn (int $n) => $pra($n - 1, 'pravnúča', '%s pravnúčaťa'))->ancestor(),
            // Aunts and uncles
            Relationship::fixed('ujo', '%s uja')->mother()->brother(),
            Relationship::fixed('ujčiná', '%s ujčinej')->mother()->brother()->wife(),
            Relationship::fixed('stryná', '%s strynej')->father()->brother()->wife(),
            Relationship::fixed('strýko', '%s strýka')->parent()->brother(),
            Relationship::fixed('teta', '%s tety')->parent()->sister(),
            // Great-aunts and great-uncles
            Relationship::dynamic(static fn (int $n) => $pra($n - 2, 'prastrýko', '%s prastrýka'))->ancestor()->brother(),
            Relationship::dynamic(static fn (int $n) => $pra($n - 2, 'prateta', '%s pratety'))->ancestor()->sister(),
            // Nieces and nephews
            Relationship::fixed('synovec', '%s synovca')->sibling()->son(),
            Relationship::fixed('neter', '%s netere')->sibling()->daughter(),
            // Great-nieces and great-nephews
            Relationship::fixed('prasynovec', '%s prasynovca')->sibling()->child()->son(),
            Relationship::fixed('praneter', '%s pranetere')->sibling()->child()->daughter(),
            Relationship::dynamic(static fn (int $n) => $pra($n - 2, 'prasynovec', '%s prasynovca'))->sibling()->descendant()->son(),
            Relationship::dynamic(static fn (int $n) => $pra($n - 2, 'praneter', '%s pranetere'))->sibling()->descendant()->daughter(),
            // Cousins
            Relationship::dynamic(static fn (int $n): array => $cousin($n, static::FEMALE_COUSINS, '', ''))->symmetricCousin()->female(),
            Relationship::dynamic(static fn (int $n): array => $cousin($n, static::MALE_COUSINS, '', ''))->symmetricCousin()->male(),
            Relationship::dynamic(static fn (int $n): array => $cousin($n, static::MALE_COUSINS, '', ''))->symmetricCousin(),
        ];
    }
}