1<?php 2 3/** 4 * webtrees: online genealogy 5 * Copyright (C) 2021 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\LocaleFr; 23use Fisharebest\Localization\Locale\LocaleInterface; 24use Fisharebest\Webtrees\Relationship; 25 26/** 27 * Class LanguageFrench. 28 */ 29class LanguageFrench extends AbstractModule implements ModuleLanguageInterface 30{ 31 use ModuleLanguageTrait; 32 33 protected const SYMMETRIC_COUSINS = [ 34 1 => [ 35 'F' => ['cousine germaine', '$s de la cousine germaine'], 36 'M' => ['cousin germain', '$s du cousin germain'], 37 'U' => ['cousin germain', '%s du cousin germain' ] 38 ], 39 2 => [ 40 'F' => ['cousine issue de germain', '$s de la cousine issue de germain'], 41 'M' => ['cousin issu de germain', '$s du cousin issu de germain'], 42 'U' => ['cousin issu de germain', '%s du cousin issu de germain' ] 43 ] 44 ]; 45 46 protected const ASYMMETRIC_COUSINS = [ 47 1 => [ 48 'F' => ['down', 'petite-', 'cousine', 'de la ', 'de la '], 49 'M' => ['down', 'petit-', 'cousin', 'du ', 'du '], 50 'U' => ['down', 'petit-', 'cousin', 'du ', 'du '] 51 ], 52 -1 => [ 53 'F' => ['up', 'grand-', 'cousine', 'de la ', 'de la '], 54 'M' => ['up', 'grand-', 'cousin', 'du ', 'du '], 55 'U' => ['up', 'grand-', 'cousin', 'du ', 'du '] 56 ], 57 ]; 58 59 /** 60 * @return LocaleInterface 61 */ 62 public function locale(): LocaleInterface 63 { 64 return new LocaleFr(); 65 } 66 67 public function relationships(): array 68 { 69 $genitive = fn (string $s, string $genitive_link): array => [$s, '%s ' . $genitive_link . $s]; 70 71 $great = fn (int $n, string $suffix, string $genitive_link): array => $genitive( 72 ($n > 2 ? 'arrière-(x' . $n . ')-' : str_repeat('arrière-', max($n, 0))) . $suffix, 73 $n === 0 ? $genitive_link : 'de l’' 74 ); 75 76 $compoundgreat = 77 fn (int $n, string $first_level, string $suffix, string $genitive_none, string $genitive_first): array => 78 $great($n - 1, ($n > 0 ? $first_level : '' ) . $suffix, $n === 0 ? $genitive_none : $genitive_first); 79 80 $symmetricCousin = fn(int $n, string $sex): array => self::SYMMETRIC_COUSINS[$n][$sex] ?? $genitive( 81 $sex === 'F' ? 'cousine au ' . $n . '<sup>e</sup> degré' : 'cousin au ' . $n . '<sup>e</sup> degré', 82 $sex === 'F' ? 'de la ' : 'du ' 83 ); 84 85 $asymmetricCousin = 86 function (int $up, int $down, string $sex) use ($symmetricCousin, $compoundgreat, $genitive): array { 87 if ($up === $down) { 88 return $symmetricCousin($up, $sex); 89 } 90 $fixed = self::ASYMMETRIC_COUSINS[$up][$sex] ?? self::ASYMMETRIC_COUSINS[-$down][$sex] ?? null; 91 if ($fixed !== null) { 92 $fixed[0] = $fixed[0] === 'up' ? $up - 1 : $down - 1; 93 return $compoundgreat(...$fixed); 94 } 95 return $genitive( 96 $sex === 'F' ? 97 'cousine du ' . $down . '<sup>e</sup> au ' . $up . '<sup>e</sup> degré' : 98 'cousin du ' . $down . '<sup>e</sup> au ' . $up . '<sup>e</sup> degré', 99 $sex === 'F' ? 'de la ' : 'du ' 100 ); 101 }; 102 103 return [ 104 // Adopted 105 Relationship::fixed('mère adoptive', '%s de la mère adoptive')->adoptive()->mother(), 106 Relationship::fixed('père adoptif', '%s du père adoptif')->adoptive()->father(), 107 Relationship::fixed('parent adoptif', '%s du parent adoptif')->adoptive()->parent(), 108 Relationship::fixed('fille adoptive', '%s de la fille adoptive')->adopted()->daughter(), 109 Relationship::fixed('fils adoptif', '%s du fils adoptif')->adopted()->son(), 110 Relationship::fixed('enfant adoptif', '%s de l’enfant adoptif')->adopted()->child(), 111 // Fostered 112 Relationship::fixed('mère d’accueil', '%s de la mère d’acceuil')->fostering()->mother(), 113 Relationship::fixed('père d’accueil', '%s du père d’acceuil')->fostering()->father(), 114 Relationship::fixed('parent d’accueil', '%s du parent d’acceuil')->fostering()->parent(), 115 Relationship::fixed('fille accueillie', '%s de la fille accueillie')->fostered()->daughter(), 116 Relationship::fixed('fils accueilli', '%s du fils accueilli')->fostered()->son(), 117 Relationship::fixed('enfant accueilli', '%s de l’enfant accueilli')->fostered()->child(), 118 // Parents 119 Relationship::fixed('mère', '%s de la mère')->mother(), 120 Relationship::fixed('père', '%s du père')->father(), 121 Relationship::fixed('parent', '%s du parent')->parent(), 122 // Children 123 Relationship::fixed('fille', '%s de la fille')->daughter(), 124 Relationship::fixed('fils', '%s du fils')->son(), 125 Relationship::fixed('enfant', '%s de l’enfant')->child(), 126 // Siblings 127 Relationship::fixed('sœur jumelle', '%s de la sœur jumelle')->twin()->sister(), 128 Relationship::fixed('frère jumeau', '%s du frère jumeau')->twin()->brother(), 129 Relationship::fixed('jumeau', '%s du jumeau')->twin()->sibling(), 130 Relationship::fixed('grande sœur', '%s de la grande sœur')->older()->sister(), 131 Relationship::fixed('grand frère', '%s du grand frère')->older()->brother(), 132 Relationship::fixed('grand frère/sœur', '%s du grand frère/sœur')->older()->sibling(), 133 Relationship::fixed('petite sœur', '%s de la petite sœur')->younger()->sister(), 134 Relationship::fixed('petit frère', '%s du petit-frère')->younger()->brother(), 135 Relationship::fixed('petit frère/sœur', '%s du petit frère/sœur')->younger()->sibling(), 136 Relationship::fixed('sœur', '%s de la sœur')->sister(), 137 Relationship::fixed('frère', '%s du frère')->brother(), 138 Relationship::fixed('frère/sœur', '%s du frère/sœur')->sibling(), 139 // Half-family 140 Relationship::fixed('demi-sœur', '%s de la demi-sœur')->parent()->daughter(), 141 Relationship::fixed('demi-frère', '%s du demi-frère')->parent()->son(), 142 Relationship::fixed('demi-frère/sœur', '%s du demi-frère/sœur')->parent()->child(), 143 // Stepfamily 144 Relationship::fixed('belle-mère', '%s de la belle-mère')->parent()->wife(), 145 Relationship::fixed('beau-père', '%s du beau-père')->parent()->husband(), 146 Relationship::fixed('beau-parent', '%s du beau-parent')->parent()->married()->spouse(), 147 Relationship::fixed('belle-fille', '%s de la belle-fille')->married()->spouse()->daughter(), 148 Relationship::fixed('beau-fils', '%s du beau-fils')->married()->spouse()->son(), 149 Relationship::fixed('beau-fils/fille', '%s du beau-fils/fille')->married()->spouse()->child(), 150 Relationship::fixed('quasi-sœur', '%s de la quasi-sœur')->parent()->spouse()->daughter(), 151 Relationship::fixed('quasi-frère', '%s du quasi-frère')->parent()->spouse()->son(), 152 Relationship::fixed('quasi-frère/sœur', '%s du quasi-frère/sœur')->parent()->spouse()->child(), 153 // Partners 154 Relationship::fixed('ex-épouse', '%s de l’ex-épouse')->divorced()->partner()->female(), 155 Relationship::fixed('ex-époux', '%s de l’ex-époux')->divorced()->partner()->male(), 156 Relationship::fixed('ex-conjoint', '%s de l’ex-conjoint')->divorced()->partner(), 157 Relationship::fixed('fiancée', '%s de la fiancée')->engaged()->partner()->female(), 158 Relationship::fixed('fiancé', '%s du fiancé')->engaged()->partner()->male(), 159 Relationship::fixed('épouse', '%s de l’épouse')->wife(), 160 Relationship::fixed('époux', '%s de l’époux')->husband(), 161 Relationship::fixed('époux', '%s de l’époux')->spouse(), 162 Relationship::fixed('conjoint', '%s du conjoint')->partner(), 163 // In-laws 164 Relationship::fixed('belle-mère', '%s de la belle-mère')->married()->spouse()->mother(), 165 Relationship::fixed('beau-père', '%s du beau-père')->married()->spouse()->father(), 166 Relationship::fixed('beau-parent', '%s du beau-parent')->married()->spouse()->parent(), 167 Relationship::fixed('belle-fille', '%s de la belle-fille')->child()->wife(), 168 Relationship::fixed('beau-fils', '%s du beau-fils')->child()->husband(), 169 Relationship::fixed('beau-fils/belle-fille', '%s du beau-fils/belle-fille')->child()->married()->spouse(), 170 Relationship::fixed('belle-sœur', '%s de la belle-sœur')->spouse()->sister(), 171 Relationship::fixed('beau-frère', '%s du beau-frère')->spouse()->brother(), 172 Relationship::fixed('beau-frère/belle-sœur', '%s du beau-frère/belle-sœur')->spouse()->sibling(), 173 Relationship::fixed('belle-sœur', '%s de la belle-sœur')->sibling()->wife(), 174 Relationship::fixed('beau-frère', '%s du beau-frère')->sibling()->husband(), 175 Relationship::fixed('beau-frère/belle-sœur', '%s du beau-frère/belle-sœur')->sibling()->spouse(), 176 // Grandparents and above 177 Relationship::dynamic(fn (int $n) => $great($n - 1, 'grand-mère maternelle', 'de la '))->mother()->ancestor()->female(), 178 Relationship::dynamic(fn (int $n) => $great($n - 1, 'grand-père maternel', 'du '))->mother()->ancestor()->male(), 179 Relationship::dynamic(fn (int $n) => $great($n - 1, 'grand-mère paternelle', 'de la '))->father()->ancestor()->female(), 180 Relationship::dynamic(fn (int $n) => $great($n - 1, 'grand-père paternel', 'du '))->father()->ancestor()->male(), 181 Relationship::dynamic(fn (int $n) => $great($n - 2, 'grand-mère', 'de la '))->ancestor()->female(), 182 Relationship::dynamic(fn (int $n) => $great($n - 2, 'grand-père', 'du '))->ancestor()->male(), 183 Relationship::dynamic(fn (int $n) => $great($n - 2, 'grand-parent', 'du '))->ancestor(), 184 // Grandchildren and below 185 Relationship::dynamic(fn (int $n) => $great($n - 2, 'petite-fille', 'de la '))->descendant()->female(), 186 Relationship::dynamic(fn (int $n) => $great($n - 2, 'petit-fils', 'du '))->descendant()->male(), 187 Relationship::dynamic(fn (int $n) => $great($n - 2, 'petit-enfant', 'du'))->descendant(), 188 // Collateral relatives 189 Relationship::dynamic(fn (int $n) => $compoundgreat($n - 1, 'grand-', 'tante', 'de la ', 'de la '))->ancestor()->sister(), 190 Relationship::dynamic(fn (int $n) => $compoundgreat($n - 1, 'grand-', 'tante par alliance', 'de la ', 'de la '))->ancestor()->sibling()->wife(), 191 Relationship::dynamic(fn (int $n) => $compoundgreat($n - 1, 'grand-', 'oncle', 'de l’', 'du '))->ancestor()->brother(), 192 Relationship::dynamic(fn (int $n) => $compoundgreat($n - 1, 'grand-', 'oncle par alliance', 'de l’', 'du '))->ancestor()->sibling()->husband(), 193 Relationship::dynamic(fn (int $n) => $compoundgreat($n - 1, 'petite-', 'nièce', 'de la ', 'de la '))->sibling()->descendant()->female(), 194 Relationship::dynamic(fn (int $n) => $compoundgreat($n - 1, 'petite-', 'nièce par alliance', 'de la ', 'de la '))->married()->spouse()->sibling()->descendant()->female(), 195 Relationship::dynamic(fn (int $n) => $compoundgreat($n - 1, 'petit-', 'neveu', 'du ', 'du '))->sibling()->descendant()->male(), 196 Relationship::dynamic(fn (int $n) => $compoundgreat($n - 1, 'petit-', 'neveu par alliance', 'du ', 'du '))->married()->spouse()->sibling()->descendant()->male(), 197 // Cousins (based on canon law) 198 Relationship::dynamic(fn(int $n) => $symmetricCousin($n, 'F'))->symmetricCousin()->female(), 199 Relationship::dynamic(fn(int $n) => $symmetricCousin($n, 'M'))->symmetricCousin()->male(), 200 Relationship::dynamic(fn(int $up, int $down) => $asymmetricCousin($up, $down, 'F'))->cousin()->female(), 201 Relationship::dynamic(fn(int $up, int $down) => $asymmetricCousin($up, $down, 'M'))->cousin()->male(), 202 203 ]; 204 } 205} 206