xref: /webtrees/app/Module/LanguageFrench.php (revision d8a5ab6e26bebbc1af96bac17c07d5a4fbdc5cca)
102086832SGreg Roach<?php
23976b470SGreg Roach
302086832SGreg Roach/**
402086832SGreg Roach * webtrees: online genealogy
589f7189bSGreg Roach * Copyright (C) 2021 webtrees development team
602086832SGreg Roach * This program is free software: you can redistribute it and/or modify
702086832SGreg Roach * it under the terms of the GNU General Public License as published by
802086832SGreg Roach * the Free Software Foundation, either version 3 of the License, or
902086832SGreg Roach * (at your option) any later version.
1002086832SGreg Roach * This program is distributed in the hope that it will be useful,
1102086832SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
1202086832SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1302086832SGreg Roach * GNU General Public License for more details.
1402086832SGreg Roach * You should have received a copy of the GNU General Public License
1589f7189bSGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>.
1602086832SGreg Roach */
17fcfa147eSGreg Roach
1802086832SGreg Roachdeclare(strict_types=1);
1902086832SGreg Roach
2002086832SGreg Roachnamespace Fisharebest\Webtrees\Module;
2102086832SGreg Roach
2202086832SGreg Roachuse Fisharebest\Localization\Locale\LocaleFr;
2302086832SGreg Roachuse Fisharebest\Localization\Locale\LocaleInterface;
24*d8a5ab6eSJonathan Jaubartuse Fisharebest\Webtrees\Relationship;
2502086832SGreg Roach
2602086832SGreg Roach/**
2702086832SGreg Roach * Class LanguageFrench.
2802086832SGreg Roach */
2902086832SGreg Roachclass LanguageFrench extends AbstractModule implements ModuleLanguageInterface
3002086832SGreg Roach{
3102086832SGreg Roach    use ModuleLanguageTrait;
3202086832SGreg Roach
33*d8a5ab6eSJonathan Jaubart    protected const SYMMETRIC_COUSINS = [
34*d8a5ab6eSJonathan Jaubart        1 => [
35*d8a5ab6eSJonathan Jaubart            'F' => ['cousine germaine', '$s de la cousine germaine'],
36*d8a5ab6eSJonathan Jaubart            'M' => ['cousin germain', '$s du cousin germain'],
37*d8a5ab6eSJonathan Jaubart            'U' => ['cousin germain', '%s du cousin germain' ]
38*d8a5ab6eSJonathan Jaubart        ],
39*d8a5ab6eSJonathan Jaubart        2 => [
40*d8a5ab6eSJonathan Jaubart            'F' => ['cousine issue de germain', '$s de la cousine issue de germain'],
41*d8a5ab6eSJonathan Jaubart            'M' => ['cousin issu de germain', '$s du cousin issu de germain'],
42*d8a5ab6eSJonathan Jaubart            'U' => ['cousin issu de germain', '%s du cousin issu de germain' ]
43*d8a5ab6eSJonathan Jaubart        ]
44*d8a5ab6eSJonathan Jaubart    ];
45*d8a5ab6eSJonathan Jaubart
46*d8a5ab6eSJonathan Jaubart    protected const ASYMMETRIC_COUSINS = [
47*d8a5ab6eSJonathan Jaubart        1 => [
48*d8a5ab6eSJonathan Jaubart            'F' => ['down', 'petite-', 'cousine', 'de la ', 'de la '],
49*d8a5ab6eSJonathan Jaubart            'M' => ['down', 'petit-', 'cousin', 'du ', 'du '],
50*d8a5ab6eSJonathan Jaubart            'U' => ['down', 'petit-', 'cousin', 'du ', 'du ']
51*d8a5ab6eSJonathan Jaubart        ],
52*d8a5ab6eSJonathan Jaubart        -1 => [
53*d8a5ab6eSJonathan Jaubart            'F' => ['up', 'grand-', 'cousine', 'de la ', 'de la '],
54*d8a5ab6eSJonathan Jaubart            'M' => ['up', 'grand-', 'cousin', 'du ', 'du '],
55*d8a5ab6eSJonathan Jaubart            'U' => ['up', 'grand-', 'cousin', 'du ', 'du ']
56*d8a5ab6eSJonathan Jaubart        ],
57*d8a5ab6eSJonathan Jaubart    ];
58*d8a5ab6eSJonathan Jaubart
5902086832SGreg Roach    /**
6002086832SGreg Roach     * @return LocaleInterface
6102086832SGreg Roach     */
6202086832SGreg Roach    public function locale(): LocaleInterface
6302086832SGreg Roach    {
6402086832SGreg Roach        return new LocaleFr();
6502086832SGreg Roach    }
66*d8a5ab6eSJonathan Jaubart
67*d8a5ab6eSJonathan Jaubart    public function relationships(): array
68*d8a5ab6eSJonathan Jaubart    {
69*d8a5ab6eSJonathan Jaubart        $genitive = fn (string $s, string $genitive_link): array => [$s, '%s ' . $genitive_link . $s];
70*d8a5ab6eSJonathan Jaubart
71*d8a5ab6eSJonathan Jaubart        $great = fn (int $n, string $suffix, string $genitive_link): array => $genitive(
72*d8a5ab6eSJonathan Jaubart            ($n > 2 ? 'arrière-(x' . $n . ')-' : str_repeat('arrière-', max($n, 0))) . $suffix,
73*d8a5ab6eSJonathan Jaubart            $n === 0 ? $genitive_link : 'de l’'
74*d8a5ab6eSJonathan Jaubart        );
75*d8a5ab6eSJonathan Jaubart
76*d8a5ab6eSJonathan Jaubart        $compoundgreat =
77*d8a5ab6eSJonathan Jaubart            fn (int $n, string $first_level, string $suffix, string $genitive_none, string $genitive_first): array =>
78*d8a5ab6eSJonathan Jaubart                $great($n - 1, ($n > 0 ? $first_level : '' ) . $suffix, $n === 0 ? $genitive_none : $genitive_first);
79*d8a5ab6eSJonathan Jaubart
80*d8a5ab6eSJonathan Jaubart        $symmetricCousin = fn(int $n, string $sex): array  => self::SYMMETRIC_COUSINS[$n][$sex] ?? $genitive(
81*d8a5ab6eSJonathan Jaubart            $sex === 'F' ? 'cousine au ' . $n . '<sup>e</sup> degré' : 'cousin au ' . $n . '<sup>e</sup> degré',
82*d8a5ab6eSJonathan Jaubart            $sex === 'F'  ? 'de la ' : 'du '
83*d8a5ab6eSJonathan Jaubart        );
84*d8a5ab6eSJonathan Jaubart
85*d8a5ab6eSJonathan Jaubart        $asymmetricCousin =
86*d8a5ab6eSJonathan Jaubart            function (int $up, int $down, string $sex) use ($symmetricCousin, $compoundgreat, $genitive): array {
87*d8a5ab6eSJonathan Jaubart                if ($up === $down) {
88*d8a5ab6eSJonathan Jaubart                    return $symmetricCousin($up, $sex);
89*d8a5ab6eSJonathan Jaubart                }
90*d8a5ab6eSJonathan Jaubart                $fixed = self::ASYMMETRIC_COUSINS[$up][$sex] ?? self::ASYMMETRIC_COUSINS[-$down][$sex] ?? null;
91*d8a5ab6eSJonathan Jaubart                if ($fixed !== null) {
92*d8a5ab6eSJonathan Jaubart                    $fixed[0] = $fixed[0] === 'up' ? $up - 1 : $down - 1;
93*d8a5ab6eSJonathan Jaubart                    return $compoundgreat(...$fixed);
94*d8a5ab6eSJonathan Jaubart                }
95*d8a5ab6eSJonathan Jaubart                return $genitive(
96*d8a5ab6eSJonathan Jaubart                    $sex === 'F' ?
97*d8a5ab6eSJonathan Jaubart                        'cousine du ' . $down . '<sup>e</sup> au ' . $up . '<sup>e</sup> degré' :
98*d8a5ab6eSJonathan Jaubart                        'cousin du ' . $down . '<sup>e</sup> au ' . $up . '<sup>e</sup> degré',
99*d8a5ab6eSJonathan Jaubart                    $sex === 'F'  ? 'de la ' : 'du '
100*d8a5ab6eSJonathan Jaubart                );
101*d8a5ab6eSJonathan Jaubart            };
102*d8a5ab6eSJonathan Jaubart
103*d8a5ab6eSJonathan Jaubart        return [
104*d8a5ab6eSJonathan Jaubart            // Adopted
105*d8a5ab6eSJonathan Jaubart            Relationship::fixed('mère adoptive', '%s de la mère adoptive')->adoptive()->mother(),
106*d8a5ab6eSJonathan Jaubart            Relationship::fixed('père adoptif', '%s du père adoptif')->adoptive()->father(),
107*d8a5ab6eSJonathan Jaubart            Relationship::fixed('parent adoptif', '%s du parent adoptif')->adoptive()->parent(),
108*d8a5ab6eSJonathan Jaubart            Relationship::fixed('fille adoptive', '%s de la fille adoptive')->adopted()->daughter(),
109*d8a5ab6eSJonathan Jaubart            Relationship::fixed('fils adoptif', '%s du fils adoptif')->adopted()->son(),
110*d8a5ab6eSJonathan Jaubart            Relationship::fixed('enfant adoptif', '%s de l’enfant adoptif')->adopted()->child(),
111*d8a5ab6eSJonathan Jaubart            // Fostered
112*d8a5ab6eSJonathan Jaubart            Relationship::fixed('mère d’accueil', '%s de la mère d’acceuil')->fostering()->mother(),
113*d8a5ab6eSJonathan Jaubart            Relationship::fixed('père d’accueil', '%s du père d’acceuil')->fostering()->father(),
114*d8a5ab6eSJonathan Jaubart            Relationship::fixed('parent d’accueil', '%s du parent d’acceuil')->fostering()->parent(),
115*d8a5ab6eSJonathan Jaubart            Relationship::fixed('fille accueillie', '%s de la fille accueillie')->fostered()->daughter(),
116*d8a5ab6eSJonathan Jaubart            Relationship::fixed('fils accueilli', '%s du fils accueilli')->fostered()->son(),
117*d8a5ab6eSJonathan Jaubart            Relationship::fixed('enfant accueilli', '%s de l’enfant accueilli')->fostered()->child(),
118*d8a5ab6eSJonathan Jaubart            // Parents
119*d8a5ab6eSJonathan Jaubart            Relationship::fixed('mère', '%s de la mère')->mother(),
120*d8a5ab6eSJonathan Jaubart            Relationship::fixed('père', '%s du père')->father(),
121*d8a5ab6eSJonathan Jaubart            Relationship::fixed('parent', '%s du parent')->parent(),
122*d8a5ab6eSJonathan Jaubart            // Children
123*d8a5ab6eSJonathan Jaubart            Relationship::fixed('fille', '%s de la fille')->daughter(),
124*d8a5ab6eSJonathan Jaubart            Relationship::fixed('fils', '%s du fils')->son(),
125*d8a5ab6eSJonathan Jaubart            Relationship::fixed('enfant', '%s de l’enfant')->child(),
126*d8a5ab6eSJonathan Jaubart            // Siblings
127*d8a5ab6eSJonathan Jaubart            Relationship::fixed('sœur jumelle', '%s de la sœur jumelle')->twin()->sister(),
128*d8a5ab6eSJonathan Jaubart            Relationship::fixed('frère jumeau', '%s du frère jumeau')->twin()->brother(),
129*d8a5ab6eSJonathan Jaubart            Relationship::fixed('jumeau', '%s du jumeau')->twin()->sibling(),
130*d8a5ab6eSJonathan Jaubart            Relationship::fixed('grande sœur', '%s de la grande sœur')->older()->sister(),
131*d8a5ab6eSJonathan Jaubart            Relationship::fixed('grand frère', '%s du grand frère')->older()->brother(),
132*d8a5ab6eSJonathan Jaubart            Relationship::fixed('grand frère/sœur', '%s du grand frère/sœur')->older()->sibling(),
133*d8a5ab6eSJonathan Jaubart            Relationship::fixed('petite sœur', '%s de la petite sœur')->younger()->sister(),
134*d8a5ab6eSJonathan Jaubart            Relationship::fixed('petit frère', '%s du petit-frère')->younger()->brother(),
135*d8a5ab6eSJonathan Jaubart            Relationship::fixed('petit frère/sœur', '%s du petit frère/sœur')->younger()->sibling(),
136*d8a5ab6eSJonathan Jaubart            Relationship::fixed('sœur', '%s de la sœur')->sister(),
137*d8a5ab6eSJonathan Jaubart            Relationship::fixed('frère', '%s du frère')->brother(),
138*d8a5ab6eSJonathan Jaubart            Relationship::fixed('frère/sœur', '%s du frère/sœur')->sibling(),
139*d8a5ab6eSJonathan Jaubart            // Half-family
140*d8a5ab6eSJonathan Jaubart            Relationship::fixed('demi-sœur', '%s de la demi-sœur')->parent()->daughter(),
141*d8a5ab6eSJonathan Jaubart            Relationship::fixed('demi-frère', '%s du demi-frère')->parent()->son(),
142*d8a5ab6eSJonathan Jaubart            Relationship::fixed('demi-frère/sœur', '%s du demi-frère/sœur')->parent()->child(),
143*d8a5ab6eSJonathan Jaubart            // Stepfamily
144*d8a5ab6eSJonathan Jaubart            Relationship::fixed('belle-mère', '%s de la belle-mère')->parent()->wife(),
145*d8a5ab6eSJonathan Jaubart            Relationship::fixed('beau-père', '%s du beau-père')->parent()->husband(),
146*d8a5ab6eSJonathan Jaubart            Relationship::fixed('beau-parent', '%s du beau-parent')->parent()->married()->spouse(),
147*d8a5ab6eSJonathan Jaubart            Relationship::fixed('belle-fille', '%s de la belle-fille')->married()->spouse()->daughter(),
148*d8a5ab6eSJonathan Jaubart            Relationship::fixed('beau-fils', '%s du beau-fils')->married()->spouse()->son(),
149*d8a5ab6eSJonathan Jaubart            Relationship::fixed('beau-fils/fille', '%s du beau-fils/fille')->married()->spouse()->child(),
150*d8a5ab6eSJonathan Jaubart            Relationship::fixed('quasi-sœur', '%s de la quasi-sœur')->parent()->spouse()->daughter(),
151*d8a5ab6eSJonathan Jaubart            Relationship::fixed('quasi-frère', '%s du quasi-frère')->parent()->spouse()->son(),
152*d8a5ab6eSJonathan Jaubart            Relationship::fixed('quasi-frère/sœur', '%s du quasi-frère/sœur')->parent()->spouse()->child(),
153*d8a5ab6eSJonathan Jaubart            // Partners
154*d8a5ab6eSJonathan Jaubart            Relationship::fixed('ex-épouse', '%s de l’ex-épouse')->divorced()->partner()->female(),
155*d8a5ab6eSJonathan Jaubart            Relationship::fixed('ex-époux', '%s de l’ex-époux')->divorced()->partner()->male(),
156*d8a5ab6eSJonathan Jaubart            Relationship::fixed('ex-conjoint', '%s de l’ex-conjoint')->divorced()->partner(),
157*d8a5ab6eSJonathan Jaubart            Relationship::fixed('fiancée', '%s de la fiancée')->engaged()->partner()->female(),
158*d8a5ab6eSJonathan Jaubart            Relationship::fixed('fiancé', '%s du fiancé')->engaged()->partner()->male(),
159*d8a5ab6eSJonathan Jaubart            Relationship::fixed('épouse', '%s de l’épouse')->wife(),
160*d8a5ab6eSJonathan Jaubart            Relationship::fixed('époux', '%s de l’époux')->husband(),
161*d8a5ab6eSJonathan Jaubart            Relationship::fixed('époux', '%s de l’époux')->spouse(),
162*d8a5ab6eSJonathan Jaubart            Relationship::fixed('conjoint', '%s du conjoint')->partner(),
163*d8a5ab6eSJonathan Jaubart            // In-laws
164*d8a5ab6eSJonathan Jaubart            Relationship::fixed('belle-mère', '%s de la belle-mère')->married()->spouse()->mother(),
165*d8a5ab6eSJonathan Jaubart            Relationship::fixed('beau-père', '%s du beau-père')->married()->spouse()->father(),
166*d8a5ab6eSJonathan Jaubart            Relationship::fixed('beau-parent', '%s du beau-parent')->married()->spouse()->parent(),
167*d8a5ab6eSJonathan Jaubart            Relationship::fixed('belle-fille', '%s de la belle-fille')->child()->wife(),
168*d8a5ab6eSJonathan Jaubart            Relationship::fixed('beau-fils', '%s du beau-fils')->child()->husband(),
169*d8a5ab6eSJonathan Jaubart            Relationship::fixed('beau-fils/belle-fille', '%s du beau-fils/belle-fille')->child()->married()->spouse(),
170*d8a5ab6eSJonathan Jaubart            Relationship::fixed('belle-sœur', '%s de la belle-sœur')->spouse()->sister(),
171*d8a5ab6eSJonathan Jaubart            Relationship::fixed('beau-frère', '%s du beau-frère')->spouse()->brother(),
172*d8a5ab6eSJonathan Jaubart            Relationship::fixed('beau-frère/belle-sœur', '%s du beau-frère/belle-sœur')->spouse()->sibling(),
173*d8a5ab6eSJonathan Jaubart            Relationship::fixed('belle-sœur', '%s de la belle-sœur')->sibling()->wife(),
174*d8a5ab6eSJonathan Jaubart            Relationship::fixed('beau-frère', '%s du beau-frère')->sibling()->husband(),
175*d8a5ab6eSJonathan Jaubart            Relationship::fixed('beau-frère/belle-sœur', '%s du beau-frère/belle-sœur')->sibling()->spouse(),
176*d8a5ab6eSJonathan Jaubart            // Grandparents and above
177*d8a5ab6eSJonathan Jaubart            Relationship::dynamic(fn (int $n) => $great($n - 1, 'grand-mère maternelle', 'de la '))->mother()->ancestor()->female(),
178*d8a5ab6eSJonathan Jaubart            Relationship::dynamic(fn (int $n) => $great($n - 1, 'grand-père maternel', 'du '))->mother()->ancestor()->male(),
179*d8a5ab6eSJonathan Jaubart            Relationship::dynamic(fn (int $n) => $great($n - 1, 'grand-mère paternelle', 'de la '))->father()->ancestor()->female(),
180*d8a5ab6eSJonathan Jaubart            Relationship::dynamic(fn (int $n) => $great($n - 1, 'grand-père paternel', 'du '))->father()->ancestor()->male(),
181*d8a5ab6eSJonathan Jaubart            Relationship::dynamic(fn (int $n) => $great($n - 2, 'grand-mère', 'de la '))->ancestor()->female(),
182*d8a5ab6eSJonathan Jaubart            Relationship::dynamic(fn (int $n) => $great($n - 2, 'grand-père', 'du '))->ancestor()->male(),
183*d8a5ab6eSJonathan Jaubart            Relationship::dynamic(fn (int $n) => $great($n - 2, 'grand-parent', 'du '))->ancestor(),
184*d8a5ab6eSJonathan Jaubart            // Grandchildren and below
185*d8a5ab6eSJonathan Jaubart            Relationship::dynamic(fn (int $n) => $great($n - 2, 'petite-fille', 'de la '))->descendant()->female(),
186*d8a5ab6eSJonathan Jaubart            Relationship::dynamic(fn (int $n) => $great($n - 2, 'petit-fils', 'du '))->descendant()->male(),
187*d8a5ab6eSJonathan Jaubart            Relationship::dynamic(fn (int $n) => $great($n - 2, 'petit-enfant', 'du'))->descendant(),
188*d8a5ab6eSJonathan Jaubart            // Collateral relatives
189*d8a5ab6eSJonathan Jaubart            Relationship::dynamic(fn (int $n) => $compoundgreat($n - 1, 'grand-', 'tante', 'de la ', 'de la '))->ancestor()->sister(),
190*d8a5ab6eSJonathan Jaubart            Relationship::dynamic(fn (int $n) => $compoundgreat($n - 1, 'grand-', 'tante par alliance', 'de la ', 'de la '))->ancestor()->sibling()->wife(),
191*d8a5ab6eSJonathan Jaubart            Relationship::dynamic(fn (int $n) => $compoundgreat($n - 1, 'grand-', 'oncle', 'de l’', 'du '))->ancestor()->brother(),
192*d8a5ab6eSJonathan Jaubart            Relationship::dynamic(fn (int $n) => $compoundgreat($n - 1, 'grand-', 'oncle par alliance', 'de l’', 'du '))->ancestor()->sibling()->husband(),
193*d8a5ab6eSJonathan Jaubart            Relationship::dynamic(fn (int $n) => $compoundgreat($n - 1, 'petite-', 'nièce', 'de la ', 'de la '))->sibling()->descendant()->female(),
194*d8a5ab6eSJonathan Jaubart            Relationship::dynamic(fn (int $n) => $compoundgreat($n - 1, 'petite-', 'nièce par alliance', 'de la ', 'de la '))->married()->spouse()->sibling()->descendant()->female(),
195*d8a5ab6eSJonathan Jaubart            Relationship::dynamic(fn (int $n) => $compoundgreat($n - 1, 'petit-', 'neveu', 'du ', 'du '))->sibling()->descendant()->male(),
196*d8a5ab6eSJonathan Jaubart            Relationship::dynamic(fn (int $n) => $compoundgreat($n - 1, 'petit-', 'neveu par alliance', 'du ', 'du '))->married()->spouse()->sibling()->descendant()->male(),
197*d8a5ab6eSJonathan Jaubart            // Cousins (based on canon law)
198*d8a5ab6eSJonathan Jaubart            Relationship::dynamic(fn(int $n) => $symmetricCousin($n, 'F'))->symmetricCousin()->female(),
199*d8a5ab6eSJonathan Jaubart            Relationship::dynamic(fn(int $n) => $symmetricCousin($n, 'M'))->symmetricCousin()->male(),
200*d8a5ab6eSJonathan Jaubart            Relationship::dynamic(fn(int $up, int $down) => $asymmetricCousin($up, $down, 'F'))->asymmetricCousin()->female(),
201*d8a5ab6eSJonathan Jaubart            Relationship::dynamic(fn(int $up, int $down) => $asymmetricCousin($up, $down, 'M'))->asymmetricCousin()->male(),
202*d8a5ab6eSJonathan Jaubart
203*d8a5ab6eSJonathan Jaubart        ];
204*d8a5ab6eSJonathan Jaubart    }
20502086832SGreg Roach}
206