102086832SGreg Roach<?php 23976b470SGreg Roach 302086832SGreg Roach/** 402086832SGreg Roach * webtrees: online genealogy 55bfc6897SGreg Roach * Copyright (C) 2022 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\LocaleEnUs; 2302086832SGreg Roachuse Fisharebest\Localization\Locale\LocaleInterface; 246fcafd02SGreg Roachuse Fisharebest\Webtrees\Relationship; 256fcafd02SGreg Roach 266fcafd02SGreg Roachuse function abs; 276fcafd02SGreg Roachuse function min; 286fcafd02SGreg Roachuse function str_repeat; 2902086832SGreg Roach 3002086832SGreg Roach/** 3102086832SGreg Roach * Class LanguageEnglishUnitedStates. 3202086832SGreg Roach */ 3302086832SGreg Roachclass LanguageEnglishUnitedStates extends AbstractModule implements ModuleLanguageInterface 3402086832SGreg Roach{ 3502086832SGreg Roach use ModuleLanguageTrait; 3602086832SGreg Roach 376fcafd02SGreg Roach protected const COUSIN = [ 386fcafd02SGreg Roach 'sibling', 396fcafd02SGreg Roach 'first cousin', 406fcafd02SGreg Roach 'second cousin', 416fcafd02SGreg Roach 'third cousin', 426fcafd02SGreg Roach 'fourth cousin', 436fcafd02SGreg Roach 'fifth cousin', 446fcafd02SGreg Roach 'sixth cousin', 456fcafd02SGreg Roach 'seventh cousin', 466fcafd02SGreg Roach 'eighth cousin', 476fcafd02SGreg Roach 'ninth cousin', 486fcafd02SGreg Roach 'tenth cousin', 496fcafd02SGreg Roach 'eleventh cousin', 506fcafd02SGreg Roach 'twelfth cousin', 516fcafd02SGreg Roach 'thirteenth cousin', 526fcafd02SGreg Roach 'fourteenth cousin', 536fcafd02SGreg Roach 'fifteenth cousin', 546fcafd02SGreg Roach 'sixteenth cousin', 556fcafd02SGreg Roach 'seventeenth cousin', 566fcafd02SGreg Roach 'eighteenth cousin', 576fcafd02SGreg Roach 'nineteenth cousin', 586fcafd02SGreg Roach 'twentieth cousin', 596fcafd02SGreg Roach 'twenty-first cousin', 606fcafd02SGreg Roach 'twenty-second cousin', 616fcafd02SGreg Roach 'twenty-third cousin', 626fcafd02SGreg Roach 'twenty-fourth cousin', 636fcafd02SGreg Roach 'twenty-fifth cousin', 646fcafd02SGreg Roach 'twenty-sixth cousin', 656fcafd02SGreg Roach 'twenty-seventh cousin', 666fcafd02SGreg Roach 'twenty-eighth cousin', 676fcafd02SGreg Roach 'twenty-ninth cousin', 686fcafd02SGreg Roach 'thirtieth cousin', 696fcafd02SGreg Roach ]; 706fcafd02SGreg Roach 716fcafd02SGreg Roach protected const REMOVED = [ 726fcafd02SGreg Roach '', 736fcafd02SGreg Roach ' once removed', 746fcafd02SGreg Roach ' twice removed', 756fcafd02SGreg Roach ' three times removed', 766fcafd02SGreg Roach ' four times removed', 776fcafd02SGreg Roach ' five times removed', 786fcafd02SGreg Roach ' six times removed', 796fcafd02SGreg Roach ' seven times removed', 806fcafd02SGreg Roach ' eight times removed', 816fcafd02SGreg Roach ' nine times removed', 826fcafd02SGreg Roach ' ten times removed', 836fcafd02SGreg Roach ' eleven removed', 846fcafd02SGreg Roach ' twelve removed', 856fcafd02SGreg Roach ' thirteen removed', 866fcafd02SGreg Roach ' fourteen times removed', 876fcafd02SGreg Roach ' fifteen times removed', 886fcafd02SGreg Roach ' sixteen times removed', 896fcafd02SGreg Roach ' seventeen times removed', 906fcafd02SGreg Roach ' eighteen times removed', 916fcafd02SGreg Roach ' nineteen times removed', 926fcafd02SGreg Roach ' twenty times removed', 936fcafd02SGreg Roach ' twenty-one times removed', 946fcafd02SGreg Roach ' twenty-two times removed', 956fcafd02SGreg Roach ' twenty-three times removed', 966fcafd02SGreg Roach ' twenty-four times removed', 976fcafd02SGreg Roach ' twenty-five times removed', 986fcafd02SGreg Roach ' twenty-six times removed', 996fcafd02SGreg Roach ' twenty-seven times removed', 1006fcafd02SGreg Roach ' twenty-eight times removed', 1016fcafd02SGreg Roach ' twenty-nine times removed', 1026fcafd02SGreg Roach ]; 1036fcafd02SGreg Roach 1046fcafd02SGreg Roach protected const DIRECTION = [ 1056fcafd02SGreg Roach -1 => ' descending', 1066fcafd02SGreg Roach 0 => '', 1076fcafd02SGreg Roach 1 => ' ascending', 1086fcafd02SGreg Roach ]; 1096fcafd02SGreg Roach 11092a78a2fSGreg Roach /** 11192a78a2fSGreg Roach * @return LocaleInterface 11292a78a2fSGreg Roach */ 11302086832SGreg Roach public function locale(): LocaleInterface 11402086832SGreg Roach { 11502086832SGreg Roach return new LocaleEnUs(); 11602086832SGreg Roach } 1176fcafd02SGreg Roach 1186fcafd02SGreg Roach /** 1196fcafd02SGreg Roach * @return array<Relationship> 1206fcafd02SGreg Roach */ 1216fcafd02SGreg Roach public function relationships(): array 1226fcafd02SGreg Roach { 1236fcafd02SGreg Roach // Genitive forms in English are simple/regular, as no relationship name ends in "s". 12405babb96SGreg Roach $genitive = static fn (string $s): array => [$s, $s . '’s %s']; 1256fcafd02SGreg Roach 1266b2cb23eSGreg Roach $cousin = static fn (int $up, int $down): array => $genitive( 1276fcafd02SGreg Roach (static::COUSIN[min($up, $down)] ?? 'distant cousin') . 1286fcafd02SGreg Roach (static::REMOVED[abs($up - $down)] ?? ' many times removed') . 1296fcafd02SGreg Roach static::DIRECTION[$up <=> $down] 1306fcafd02SGreg Roach ); 1316fcafd02SGreg Roach 13205babb96SGreg Roach $great = static fn (int $n, string $prefix, string $suffix): array => $genitive( 1336fcafd02SGreg Roach $prefix . ($n > 3 ? 'great ×' . $n . ' ' : str_repeat('great-', $n)) . $suffix 1346fcafd02SGreg Roach ); 1356fcafd02SGreg Roach 1366fcafd02SGreg Roach return [ 1376fcafd02SGreg Roach // Adopted 1386fcafd02SGreg Roach Relationship::fixed('adoptive-mother', 'adoptive-mother’s %s')->adoptive()->mother(), 1396fcafd02SGreg Roach Relationship::fixed('adoptive-father', 'adoptive-father’s %s')->adoptive()->father(), 1406fcafd02SGreg Roach Relationship::fixed('adoptive-parent', 'adoptive-parent’s %s')->adoptive()->parent(), 1416fcafd02SGreg Roach Relationship::fixed('adopted-daughter', 'adopted-daughter’s %s')->adopted()->daughter(), 1426fcafd02SGreg Roach Relationship::fixed('adopted-son', 'adopted-son’s %s')->adopted()->son(), 1436fcafd02SGreg Roach Relationship::fixed('adopted-child', 'adopted-child’s %s')->adopted()->child(), 1446fcafd02SGreg Roach // Fostered 1456fcafd02SGreg Roach Relationship::fixed('foster-mother', 'foster-mother’s %s')->fostering()->mother(), 1466fcafd02SGreg Roach Relationship::fixed('foster-father', 'foster-father’s %s')->fostering()->father(), 1476fcafd02SGreg Roach Relationship::fixed('foster-parent', 'foster-parent’s %s')->fostering()->parent(), 1486fcafd02SGreg Roach Relationship::fixed('foster-daughter', 'foster-daughter’s %s')->fostered()->daughter(), 1496fcafd02SGreg Roach Relationship::fixed('foster-son', 'foster-son’s %s')->fostered()->son(), 1506fcafd02SGreg Roach Relationship::fixed('foster-child', 'foster-child’s %s')->fostered()->child(), 1516fcafd02SGreg Roach // Parents 1526fcafd02SGreg Roach Relationship::fixed('mother', 'mother’s %s')->mother(), 1536fcafd02SGreg Roach Relationship::fixed('father', 'father’s %s')->father(), 1546fcafd02SGreg Roach Relationship::fixed('parent', 'parent’s %s')->parent(), 1556fcafd02SGreg Roach // Children 1566fcafd02SGreg Roach Relationship::fixed('daughter', 'daughter’s %s')->daughter(), 1576fcafd02SGreg Roach Relationship::fixed('son', 'son’s %s')->son(), 1586fcafd02SGreg Roach Relationship::fixed('child', 'child’s %s')->child(), 1596fcafd02SGreg Roach // Siblings 1606fcafd02SGreg Roach Relationship::fixed('twin sister', 'twin sister’s %s')->twin()->sister(), 1616fcafd02SGreg Roach Relationship::fixed('twin brother', 'twin brother’s %s')->twin()->brother(), 1626fcafd02SGreg Roach Relationship::fixed('twin sibling', 'twin sibling’s %s')->twin()->sibling(), 1636fcafd02SGreg Roach Relationship::fixed('elder sister', 'elder sister’s %s')->older()->sister(), 1646fcafd02SGreg Roach Relationship::fixed('elder brother', 'elder brother’s %s')->older()->brother(), 1656fcafd02SGreg Roach Relationship::fixed('elder sibling', 'elder sibling’s %s')->older()->sibling(), 1666fcafd02SGreg Roach Relationship::fixed('younger sister', 'younger sister’s %s')->younger()->sister(), 1676fcafd02SGreg Roach Relationship::fixed('younger brother', 'younger brother’s %s')->younger()->brother(), 1686fcafd02SGreg Roach Relationship::fixed('younger sibling', 'younger sibling’s %s')->younger()->sibling(), 1696fcafd02SGreg Roach Relationship::fixed('sister', 'sister’s %s')->sister(), 1706fcafd02SGreg Roach Relationship::fixed('brother', 'brother’s %s')->brother(), 1716fcafd02SGreg Roach Relationship::fixed('sibling', 'sibling’s %s')->sibling(), 172d8a5ab6eSJonathan Jaubart // Half-siblings 173d8a5ab6eSJonathan Jaubart Relationship::fixed('half-sister', 'half-sister’s %s')->parent()->daughter(), 174d8a5ab6eSJonathan Jaubart Relationship::fixed('half-brother', 'half-brother’s %s')->parent()->son(), 175d8a5ab6eSJonathan Jaubart Relationship::fixed('half-sibling', 'half-sibling’s %s')->parent()->child(), 176d8a5ab6eSJonathan Jaubart // Stepfamily 177d8a5ab6eSJonathan Jaubart Relationship::fixed('stepmother', 'stepmother’s %s')->parent()->wife(), 178d8a5ab6eSJonathan Jaubart Relationship::fixed('stepfather', 'stepfather’s %s')->parent()->husband(), 179d8a5ab6eSJonathan Jaubart Relationship::fixed('stepparent', 'stepparent’s %s')->parent()->married()->spouse(), 180d8a5ab6eSJonathan Jaubart Relationship::fixed('stepdaughter', 'stepdaughter’s %s')->married()->spouse()->daughter(), 181d8a5ab6eSJonathan Jaubart Relationship::fixed('stepson', 'stepson’s %s')->married()->spouse()->son(), 182d8a5ab6eSJonathan Jaubart Relationship::fixed('stepchild', 'stepchild’s %s')->married()->spouse()->child(), 183d8a5ab6eSJonathan Jaubart Relationship::fixed('stepsister', 'stepsister’s %s')->parent()->spouse()->daughter(), 184d8a5ab6eSJonathan Jaubart Relationship::fixed('stepbrother', 'stepbrother’s %s')->parent()->spouse()->son(), 185d8a5ab6eSJonathan Jaubart Relationship::fixed('stepsibling', 'stepsibling’s %s')->parent()->spouse()->child(), 1866fcafd02SGreg Roach // Partners 1876fcafd02SGreg Roach Relationship::fixed('ex-wife', 'ex-wife’s %s')->divorced()->partner()->female(), 1886fcafd02SGreg Roach Relationship::fixed('ex-husband', 'ex-husband’s %s')->divorced()->partner()->male(), 1896fcafd02SGreg Roach Relationship::fixed('ex-spouse', 'ex-spouse’s %s')->divorced()->partner(), 1906fcafd02SGreg Roach Relationship::fixed('fiancée', 'fiancée’s %s')->engaged()->partner()->female(), 1916fcafd02SGreg Roach Relationship::fixed('fiancé', 'fiancé’s %s')->engaged()->partner()->male(), 1926fcafd02SGreg Roach Relationship::fixed('wife', 'wife’s %s')->wife(), 1936fcafd02SGreg Roach Relationship::fixed('husband', 'husband’s %s')->husband(), 1946fcafd02SGreg Roach Relationship::fixed('spouse', 'spouse’s %s')->spouse(), 1956fcafd02SGreg Roach Relationship::fixed('partner', 'partner’s %s')->partner(), 1966fcafd02SGreg Roach // In-laws 1976fcafd02SGreg Roach Relationship::fixed('mother-in-law', 'mother-in-law’s %s')->married()->spouse()->mother(), 1986fcafd02SGreg Roach Relationship::fixed('father-in-law', 'father-in-law’s %s')->married()->spouse()->father(), 1996fcafd02SGreg Roach Relationship::fixed('parent-in-law', 'parent-in-law’s %s')->married()->spouse()->parent(), 2006fcafd02SGreg Roach Relationship::fixed('daughter-in-law', 'daughter-in-law’s %s')->child()->wife(), 2016fcafd02SGreg Roach Relationship::fixed('son-in-law', 'son-in-law’s %s')->child()->husband(), 2026fcafd02SGreg Roach Relationship::fixed('child-in-law', 'child-in-law’s %s')->child()->married()->spouse(), 2036fcafd02SGreg Roach Relationship::fixed('sister-in-law', 'sister-in-law’s %s')->sibling()->spouse()->sister(), 2046fcafd02SGreg Roach Relationship::fixed('brother-in-law', 'brother-in-law’s %s')->sibling()->spouse()->brother(), 2056fcafd02SGreg Roach Relationship::fixed('sibling-in-law', 'sibling-in-law’s %s')->sibling()->spouse()->sibling(), 2066fcafd02SGreg Roach Relationship::fixed('sister-in-law', 'sister-in-law’s %s')->spouse()->sister(), 2076fcafd02SGreg Roach Relationship::fixed('brother-in-law', 'brother-in-law’s %s')->spouse()->brother(), 2086fcafd02SGreg Roach Relationship::fixed('sibling-in-law', 'sibling-in-law’s %s')->spouse()->sibling(), 2096fcafd02SGreg Roach Relationship::fixed('sister-in-law', 'sister-in-law’s %s')->sibling()->wife(), 2106fcafd02SGreg Roach Relationship::fixed('brother-in-law', 'brother-in-law’s %s')->sibling()->husband(), 2116fcafd02SGreg Roach Relationship::fixed('sibling-in-law', 'sibling-in-law’s %s')->sibling()->spouse(), 2126fcafd02SGreg Roach // Grandparents 2136fcafd02SGreg Roach Relationship::fixed('maternal-grandmother', 'maternal-grandmother’s %s')->mother()->mother(), 2146fcafd02SGreg Roach Relationship::fixed('maternal-grandfather', 'maternal-grandfather’s %s')->mother()->father(), 2156fcafd02SGreg Roach Relationship::fixed('maternal-grandparent', 'maternal-grandfather’s %s')->mother()->parent(), 2166fcafd02SGreg Roach Relationship::fixed('paternal-grandmother', 'paternal-grandmother’s %s')->father()->mother(), 2176fcafd02SGreg Roach Relationship::fixed('paternal-grandfather', 'paternal-grandfather’s %s')->father()->father(), 2186fcafd02SGreg Roach Relationship::fixed('paternal-grandparent', 'paternal-grandfather’s %s')->father()->parent(), 2196fcafd02SGreg Roach Relationship::fixed('grandmother', 'grandmother’s %s')->parent()->mother(), 2206fcafd02SGreg Roach Relationship::fixed('grandfather', 'grandfather’s %s')->parent()->father(), 2216fcafd02SGreg Roach Relationship::fixed('grandparent', 'grandparent’s %s')->parent()->parent(), 2226fcafd02SGreg Roach // Grandchildren 2236fcafd02SGreg Roach Relationship::fixed('granddaughter', 'granddaughter’s %s')->child()->daughter(), 2246fcafd02SGreg Roach Relationship::fixed('grandson', 'grandson’s %s')->child()->son(), 2256fcafd02SGreg Roach Relationship::fixed('grandchild', 'grandchild’s %s')->child()->child(), 2266fcafd02SGreg Roach // Relationships with dynamically generated names 2276b2cb23eSGreg Roach Relationship::dynamic(static fn (int $n) => $great($n - 1, '', 'aunt'))->ancestor()->sister(), 2286b2cb23eSGreg Roach Relationship::dynamic(static fn (int $n) => $great($n - 1, '', 'aunt'))->ancestor()->sibling()->wife(), 2296b2cb23eSGreg Roach Relationship::dynamic(static fn (int $n) => $great($n - 1, '', 'uncle'))->ancestor()->brother(), 2306b2cb23eSGreg Roach Relationship::dynamic(static fn (int $n) => $great($n - 1, '', 'uncle'))->ancestor()->sibling()->husband(), 2316b2cb23eSGreg Roach Relationship::dynamic(static fn (int $n) => $great($n - 1, '', 'niece'))->sibling()->descendant()->female(), 2326b2cb23eSGreg Roach Relationship::dynamic(static fn (int $n) => $great($n - 1, '', 'niece'))->married()->spouse()->sibling()->descendant()->female(), 2336b2cb23eSGreg Roach Relationship::dynamic(static fn (int $n) => $great($n - 1, '', 'nephew'))->sibling()->descendant()->male(), 2346b2cb23eSGreg Roach Relationship::dynamic(static fn (int $n) => $great($n - 1, '', 'nephew'))->married()->spouse()->sibling()->descendant()->male(), 235*98ebe5e4SGreg Roach Relationship::dynamic(static fn (int $n) => $great($n - 1, 'maternal ', 'grandmother'))->mother()->ancestor()->female(), 2366b2cb23eSGreg Roach Relationship::dynamic(static fn (int $n) => $great($n - 1, 'maternal ', 'grandfather'))->mother()->ancestor()->male(), 2376b2cb23eSGreg Roach Relationship::dynamic(static fn (int $n) => $great($n - 1, 'paternal ', 'grandmother'))->father()->ancestor()->female(), 2386b2cb23eSGreg Roach Relationship::dynamic(static fn (int $n) => $great($n - 1, 'paternal ', 'grandfather'))->father()->ancestor()->male(), 2396b2cb23eSGreg Roach Relationship::dynamic(static fn (int $n) => $great($n - 1, '', 'grandparent'))->ancestor(), 2406b2cb23eSGreg Roach Relationship::dynamic(static fn (int $n) => $great($n - 2, '', 'granddaughter'))->descendant()->female(), 2416b2cb23eSGreg Roach Relationship::dynamic(static fn (int $n) => $great($n - 2, '', 'grandson'))->descendant()->male(), 2426b2cb23eSGreg Roach Relationship::dynamic(static fn (int $n) => $great($n - 2, '', 'grandchild'))->descendant(), 2436fcafd02SGreg Roach Relationship::dynamic($cousin)->ancestor()->sibling()->descendant(), 2446fcafd02SGreg Roach ]; 2456fcafd02SGreg Roach } 24602086832SGreg Roach} 247