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\LocaleEnUs; 2302086832SGreg Roachuse Fisharebest\Localization\Locale\LocaleInterface; 24*6fcafd02SGreg Roachuse Fisharebest\Webtrees\Relationship; 25*6fcafd02SGreg Roach 26*6fcafd02SGreg Roachuse function abs; 27*6fcafd02SGreg Roachuse function min; 28*6fcafd02SGreg 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 37*6fcafd02SGreg Roach protected const COUSIN = [ 38*6fcafd02SGreg Roach 'sibling', 39*6fcafd02SGreg Roach 'first cousin', 40*6fcafd02SGreg Roach 'second cousin', 41*6fcafd02SGreg Roach 'third cousin', 42*6fcafd02SGreg Roach 'fourth cousin', 43*6fcafd02SGreg Roach 'fifth cousin', 44*6fcafd02SGreg Roach 'sixth cousin', 45*6fcafd02SGreg Roach 'seventh cousin', 46*6fcafd02SGreg Roach 'eighth cousin', 47*6fcafd02SGreg Roach 'ninth cousin', 48*6fcafd02SGreg Roach 'tenth cousin', 49*6fcafd02SGreg Roach 'eleventh cousin', 50*6fcafd02SGreg Roach 'twelfth cousin', 51*6fcafd02SGreg Roach 'thirteenth cousin', 52*6fcafd02SGreg Roach 'fourteenth cousin', 53*6fcafd02SGreg Roach 'fifteenth cousin', 54*6fcafd02SGreg Roach 'sixteenth cousin', 55*6fcafd02SGreg Roach 'seventeenth cousin', 56*6fcafd02SGreg Roach 'eighteenth cousin', 57*6fcafd02SGreg Roach 'nineteenth cousin', 58*6fcafd02SGreg Roach 'twentieth cousin', 59*6fcafd02SGreg Roach 'twenty-first cousin', 60*6fcafd02SGreg Roach 'twenty-second cousin', 61*6fcafd02SGreg Roach 'twenty-third cousin', 62*6fcafd02SGreg Roach 'twenty-fourth cousin', 63*6fcafd02SGreg Roach 'twenty-fifth cousin', 64*6fcafd02SGreg Roach 'twenty-sixth cousin', 65*6fcafd02SGreg Roach 'twenty-seventh cousin', 66*6fcafd02SGreg Roach 'twenty-eighth cousin', 67*6fcafd02SGreg Roach 'twenty-ninth cousin', 68*6fcafd02SGreg Roach 'thirtieth cousin', 69*6fcafd02SGreg Roach ]; 70*6fcafd02SGreg Roach 71*6fcafd02SGreg Roach protected const REMOVED = [ 72*6fcafd02SGreg Roach '', 73*6fcafd02SGreg Roach ' once removed', 74*6fcafd02SGreg Roach ' twice removed', 75*6fcafd02SGreg Roach ' three times removed', 76*6fcafd02SGreg Roach ' four times removed', 77*6fcafd02SGreg Roach ' five times removed', 78*6fcafd02SGreg Roach ' six times removed', 79*6fcafd02SGreg Roach ' seven times removed', 80*6fcafd02SGreg Roach ' eight times removed', 81*6fcafd02SGreg Roach ' nine times removed', 82*6fcafd02SGreg Roach ' ten times removed', 83*6fcafd02SGreg Roach ' eleven removed', 84*6fcafd02SGreg Roach ' twelve removed', 85*6fcafd02SGreg Roach ' thirteen removed', 86*6fcafd02SGreg Roach ' fourteen times removed', 87*6fcafd02SGreg Roach ' fifteen times removed', 88*6fcafd02SGreg Roach ' sixteen times removed', 89*6fcafd02SGreg Roach ' seventeen times removed', 90*6fcafd02SGreg Roach ' eighteen times removed', 91*6fcafd02SGreg Roach ' nineteen times removed', 92*6fcafd02SGreg Roach ' twenty times removed', 93*6fcafd02SGreg Roach ' twenty-one times removed', 94*6fcafd02SGreg Roach ' twenty-two times removed', 95*6fcafd02SGreg Roach ' twenty-three times removed', 96*6fcafd02SGreg Roach ' twenty-four times removed', 97*6fcafd02SGreg Roach ' twenty-five times removed', 98*6fcafd02SGreg Roach ' twenty-six times removed', 99*6fcafd02SGreg Roach ' twenty-seven times removed', 100*6fcafd02SGreg Roach ' twenty-eight times removed', 101*6fcafd02SGreg Roach ' twenty-nine times removed', 102*6fcafd02SGreg Roach ]; 103*6fcafd02SGreg Roach 104*6fcafd02SGreg Roach protected const DIRECTION = [ 105*6fcafd02SGreg Roach -1 => ' descending', 106*6fcafd02SGreg Roach 0 => '', 107*6fcafd02SGreg Roach 1 => ' ascending', 108*6fcafd02SGreg Roach ]; 109*6fcafd02SGreg Roach 11002086832SGreg Roach public function locale(): LocaleInterface 11102086832SGreg Roach { 11202086832SGreg Roach return new LocaleEnUs(); 11302086832SGreg Roach } 114*6fcafd02SGreg Roach 115*6fcafd02SGreg Roach /** 116*6fcafd02SGreg Roach * @return array<Relationship> 117*6fcafd02SGreg Roach */ 118*6fcafd02SGreg Roach public function relationships(): array 119*6fcafd02SGreg Roach { 120*6fcafd02SGreg Roach // Genitive forms in English are simple/regular, as no relationship name ends in "s". 121*6fcafd02SGreg Roach $genitive = fn (string $s): array => [$s, $s . '’s %s']; 122*6fcafd02SGreg Roach 123*6fcafd02SGreg Roach $cousin = fn (int $up, int $down): array => $genitive( 124*6fcafd02SGreg Roach (static::COUSIN[min($up, $down)] ?? 'distant cousin') . 125*6fcafd02SGreg Roach (static::REMOVED[abs($up - $down)] ?? ' many times removed') . 126*6fcafd02SGreg Roach static::DIRECTION[$up <=> $down] 127*6fcafd02SGreg Roach ); 128*6fcafd02SGreg Roach 129*6fcafd02SGreg Roach $great = fn (int $n, string $prefix, string $suffix): array => $genitive( 130*6fcafd02SGreg Roach $prefix . ($n > 3 ? 'great ×' . $n . ' ' : str_repeat('great-', $n)) . $suffix 131*6fcafd02SGreg Roach ); 132*6fcafd02SGreg Roach 133*6fcafd02SGreg Roach return [ 134*6fcafd02SGreg Roach // Adopted 135*6fcafd02SGreg Roach Relationship::fixed('adoptive-mother', 'adoptive-mother’s %s')->adoptive()->mother(), 136*6fcafd02SGreg Roach Relationship::fixed('adoptive-father', 'adoptive-father’s %s')->adoptive()->father(), 137*6fcafd02SGreg Roach Relationship::fixed('adoptive-parent', 'adoptive-parent’s %s')->adoptive()->parent(), 138*6fcafd02SGreg Roach Relationship::fixed('adopted-daughter', 'adopted-daughter’s %s')->adopted()->daughter(), 139*6fcafd02SGreg Roach Relationship::fixed('adopted-son', 'adopted-son’s %s')->adopted()->son(), 140*6fcafd02SGreg Roach Relationship::fixed('adopted-child', 'adopted-child’s %s')->adopted()->child(), 141*6fcafd02SGreg Roach // Fostered 142*6fcafd02SGreg Roach Relationship::fixed('foster-mother', 'foster-mother’s %s')->fostering()->mother(), 143*6fcafd02SGreg Roach Relationship::fixed('foster-father', 'foster-father’s %s')->fostering()->father(), 144*6fcafd02SGreg Roach Relationship::fixed('foster-parent', 'foster-parent’s %s')->fostering()->parent(), 145*6fcafd02SGreg Roach Relationship::fixed('foster-daughter', 'foster-daughter’s %s')->fostered()->daughter(), 146*6fcafd02SGreg Roach Relationship::fixed('foster-son', 'foster-son’s %s')->fostered()->son(), 147*6fcafd02SGreg Roach Relationship::fixed('foster-child', 'foster-child’s %s')->fostered()->child(), 148*6fcafd02SGreg Roach // Parents 149*6fcafd02SGreg Roach Relationship::fixed('mother', 'mother’s %s')->mother(), 150*6fcafd02SGreg Roach Relationship::fixed('father', 'father’s %s')->father(), 151*6fcafd02SGreg Roach Relationship::fixed('parent', 'parent’s %s')->parent(), 152*6fcafd02SGreg Roach // Children 153*6fcafd02SGreg Roach Relationship::fixed('daughter', 'daughter’s %s')->daughter(), 154*6fcafd02SGreg Roach Relationship::fixed('son', 'son’s %s')->son(), 155*6fcafd02SGreg Roach Relationship::fixed('child', 'child’s %s')->child(), 156*6fcafd02SGreg Roach // Siblings 157*6fcafd02SGreg Roach Relationship::fixed('twin sister', 'twin sister’s %s')->twin()->sister(), 158*6fcafd02SGreg Roach Relationship::fixed('twin brother', 'twin brother’s %s')->twin()->brother(), 159*6fcafd02SGreg Roach Relationship::fixed('twin sibling', 'twin sibling’s %s')->twin()->sibling(), 160*6fcafd02SGreg Roach Relationship::fixed('elder sister', 'elder sister’s %s')->older()->sister(), 161*6fcafd02SGreg Roach Relationship::fixed('elder brother', 'elder brother’s %s')->older()->brother(), 162*6fcafd02SGreg Roach Relationship::fixed('elder sibling', 'elder sibling’s %s')->older()->sibling(), 163*6fcafd02SGreg Roach Relationship::fixed('younger sister', 'younger sister’s %s')->younger()->sister(), 164*6fcafd02SGreg Roach Relationship::fixed('younger brother', 'younger brother’s %s')->younger()->brother(), 165*6fcafd02SGreg Roach Relationship::fixed('younger sibling', 'younger sibling’s %s')->younger()->sibling(), 166*6fcafd02SGreg Roach Relationship::fixed('sister', 'sister’s %s')->sister(), 167*6fcafd02SGreg Roach Relationship::fixed('brother', 'brother’s %s')->brother(), 168*6fcafd02SGreg Roach Relationship::fixed('sibling', 'sibling’s %s')->sibling(), 169*6fcafd02SGreg Roach // Partners 170*6fcafd02SGreg Roach Relationship::fixed('ex-wife', 'ex-wife’s %s')->divorced()->partner()->female(), 171*6fcafd02SGreg Roach Relationship::fixed('ex-husband', 'ex-husband’s %s')->divorced()->partner()->male(), 172*6fcafd02SGreg Roach Relationship::fixed('ex-spouse', 'ex-spouse’s %s')->divorced()->partner(), 173*6fcafd02SGreg Roach Relationship::fixed('fiancée', 'fiancée’s %s')->engaged()->partner()->female(), 174*6fcafd02SGreg Roach Relationship::fixed('fiancé', 'fiancé’s %s')->engaged()->partner()->male(), 175*6fcafd02SGreg Roach Relationship::fixed('wife', 'wife’s %s')->wife(), 176*6fcafd02SGreg Roach Relationship::fixed('husband', 'husband’s %s')->husband(), 177*6fcafd02SGreg Roach Relationship::fixed('spouse', 'spouse’s %s')->spouse(), 178*6fcafd02SGreg Roach Relationship::fixed('partner', 'partner’s %s')->partner(), 179*6fcafd02SGreg Roach // In-laws 180*6fcafd02SGreg Roach Relationship::fixed('mother-in-law', 'mother-in-law’s %s')->married()->spouse()->mother(), 181*6fcafd02SGreg Roach Relationship::fixed('father-in-law', 'father-in-law’s %s')->married()->spouse()->father(), 182*6fcafd02SGreg Roach Relationship::fixed('parent-in-law', 'parent-in-law’s %s')->married()->spouse()->parent(), 183*6fcafd02SGreg Roach Relationship::fixed('daughter-in-law', 'daughter-in-law’s %s')->child()->wife(), 184*6fcafd02SGreg Roach Relationship::fixed('son-in-law', 'son-in-law’s %s')->child()->husband(), 185*6fcafd02SGreg Roach Relationship::fixed('child-in-law', 'child-in-law’s %s')->child()->married()->spouse(), 186*6fcafd02SGreg Roach Relationship::fixed('sister-in-law', 'sister-in-law’s %s')->sibling()->spouse()->sister(), 187*6fcafd02SGreg Roach Relationship::fixed('brother-in-law', 'brother-in-law’s %s')->sibling()->spouse()->brother(), 188*6fcafd02SGreg Roach Relationship::fixed('sibling-in-law', 'sibling-in-law’s %s')->sibling()->spouse()->sibling(), 189*6fcafd02SGreg Roach Relationship::fixed('sister-in-law', 'sister-in-law’s %s')->spouse()->sister(), 190*6fcafd02SGreg Roach Relationship::fixed('brother-in-law', 'brother-in-law’s %s')->spouse()->brother(), 191*6fcafd02SGreg Roach Relationship::fixed('sibling-in-law', 'sibling-in-law’s %s')->spouse()->sibling(), 192*6fcafd02SGreg Roach Relationship::fixed('sister-in-law', 'sister-in-law’s %s')->sibling()->wife(), 193*6fcafd02SGreg Roach Relationship::fixed('brother-in-law', 'brother-in-law’s %s')->sibling()->husband(), 194*6fcafd02SGreg Roach Relationship::fixed('sibling-in-law', 'sibling-in-law’s %s')->sibling()->spouse(), 195*6fcafd02SGreg Roach // Grandparents 196*6fcafd02SGreg Roach Relationship::fixed('maternal-grandmother', 'maternal-grandmother’s %s')->mother()->mother(), 197*6fcafd02SGreg Roach Relationship::fixed('maternal-grandfather', 'maternal-grandfather’s %s')->mother()->father(), 198*6fcafd02SGreg Roach Relationship::fixed('maternal-grandparent', 'maternal-grandfather’s %s')->mother()->parent(), 199*6fcafd02SGreg Roach Relationship::fixed('paternal-grandmother', 'paternal-grandmother’s %s')->father()->mother(), 200*6fcafd02SGreg Roach Relationship::fixed('paternal-grandfather', 'paternal-grandfather’s %s')->father()->father(), 201*6fcafd02SGreg Roach Relationship::fixed('paternal-grandparent', 'paternal-grandfather’s %s')->father()->parent(), 202*6fcafd02SGreg Roach Relationship::fixed('grandmother', 'grandmother’s %s')->parent()->mother(), 203*6fcafd02SGreg Roach Relationship::fixed('grandfather', 'grandfather’s %s')->parent()->father(), 204*6fcafd02SGreg Roach Relationship::fixed('grandparent', 'grandparent’s %s')->parent()->parent(), 205*6fcafd02SGreg Roach // Grandchildren 206*6fcafd02SGreg Roach Relationship::fixed('granddaughter', 'granddaughter’s %s')->child()->daughter(), 207*6fcafd02SGreg Roach Relationship::fixed('grandson', 'grandson’s %s')->child()->son(), 208*6fcafd02SGreg Roach Relationship::fixed('grandchild', 'grandchild’s %s')->child()->child(), 209*6fcafd02SGreg Roach // Relationships with dynamically generated names 210*6fcafd02SGreg Roach Relationship::dynamic(fn (int $n) => $great($n - 1, '', 'aunt'))->ancestor()->sister(), 211*6fcafd02SGreg Roach Relationship::dynamic(fn (int $n) => $great($n - 1, '', 'aunt'))->ancestor()->sibling()->wife(), 212*6fcafd02SGreg Roach Relationship::dynamic(fn (int $n) => $great($n - 1, '', 'uncle'))->ancestor()->brother(), 213*6fcafd02SGreg Roach Relationship::dynamic(fn (int $n) => $great($n - 1, '', 'uncle'))->ancestor()->sibling()->husband(), 214*6fcafd02SGreg Roach Relationship::dynamic(fn (int $n) => $great($n - 1, '', 'niece'))->descendant()->sister(), 215*6fcafd02SGreg Roach Relationship::dynamic(fn (int $n) => $great($n - 1, '', 'niece'))->married()->spouse()->sibling()->descendant()->female(), 216*6fcafd02SGreg Roach Relationship::dynamic(fn (int $n) => $great($n - 1, '', 'nephew'))->sibling()->descendant()->male(), 217*6fcafd02SGreg Roach Relationship::dynamic(fn (int $n) => $great($n - 1, '', 'nephew'))->married()->spouse()->sibling()->descendant()->male(), 218*6fcafd02SGreg Roach Relationship::dynamic(fn (int $n) => $great($n - 2, 'maternal ', 'grandmother'))->mother()->ancestor()->female(), 219*6fcafd02SGreg Roach Relationship::dynamic(fn (int $n) => $great($n - 1, 'maternal ', 'grandfather'))->mother()->ancestor()->male(), 220*6fcafd02SGreg Roach Relationship::dynamic(fn (int $n) => $great($n - 1, 'paternal ', 'grandmother'))->father()->ancestor()->female(), 221*6fcafd02SGreg Roach Relationship::dynamic(fn (int $n) => $great($n - 1, 'paternal ', 'grandfather'))->father()->ancestor()->male(), 222*6fcafd02SGreg Roach Relationship::dynamic(fn (int $n) => $great($n - 1, '', 'grandparent'))->ancestor(), 223*6fcafd02SGreg Roach Relationship::dynamic(fn (int $n) => $great($n - 2, '', 'granddaughter'))->descendant()->female(), 224*6fcafd02SGreg Roach Relationship::dynamic(fn (int $n) => $great($n - 2, '', 'grandson'))->descendant()->male(), 225*6fcafd02SGreg Roach Relationship::dynamic(fn (int $n) => $great($n - 2, '', 'grandchild'))->descendant(), 226*6fcafd02SGreg Roach Relationship::dynamic($cousin)->ancestor()->sibling()->descendant(), 227*6fcafd02SGreg Roach ]; 228*6fcafd02SGreg Roach } 22902086832SGreg Roach} 230