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