xref: /webtrees/app/Module/LanguageEnglishUnitedStates.php (revision e873f434551745f888937263ff89e80db3b0f785)
102086832SGreg Roach<?php
23976b470SGreg Roach
302086832SGreg Roach/**
402086832SGreg Roach * webtrees: online genealogy
5d11be702SGreg Roach * Copyright (C) 2023 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
37*e873f434SGreg Roach    protected const array 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
71*e873f434SGreg Roach    protected const array 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
104*e873f434SGreg Roach    protected const array DIRECTION = [
1056fcafd02SGreg Roach        -1 => ' descending',
1066fcafd02SGreg Roach        0  => '',
1076fcafd02SGreg Roach        1  => ' ascending',
1086fcafd02SGreg Roach    ];
1096fcafd02SGreg Roach
11092a78a2fSGreg Roach    /**
1114a9a6095SGreg Roach     * One of: 'DMY', 'MDY', 'YMD'.
1124a9a6095SGreg Roach     *
1134a9a6095SGreg Roach     * @return string
1144a9a6095SGreg Roach     */
1154a9a6095SGreg Roach    public function dateOrder(): string
1164a9a6095SGreg Roach    {
1174a9a6095SGreg Roach        return 'MDY';
1184a9a6095SGreg Roach    }
1194a9a6095SGreg Roach
1204a9a6095SGreg Roach    /**
12192a78a2fSGreg Roach     * @return LocaleInterface
12292a78a2fSGreg Roach     */
12302086832SGreg Roach    public function locale(): LocaleInterface
12402086832SGreg Roach    {
12502086832SGreg Roach        return new LocaleEnUs();
12602086832SGreg Roach    }
1276fcafd02SGreg Roach
1286fcafd02SGreg Roach    /**
1296fcafd02SGreg Roach     * @return array<Relationship>
1306fcafd02SGreg Roach     */
1316fcafd02SGreg Roach    public function relationships(): array
1326fcafd02SGreg Roach    {
1336fcafd02SGreg Roach        // Genitive forms in English are simple/regular, as no relationship name ends in "s".
13405babb96SGreg Roach        $genitive = static fn (string $s): array => [$s, $s . '’s %s'];
1356fcafd02SGreg Roach
1366b2cb23eSGreg Roach        $cousin = static fn (int $up, int $down): array => $genitive(
1376fcafd02SGreg Roach            (static::COUSIN[min($up, $down)] ?? 'distant cousin') .
1386fcafd02SGreg Roach            (static::REMOVED[abs($up - $down)] ?? ' many times removed') .
1396fcafd02SGreg Roach            static::DIRECTION[$up <=> $down]
1406fcafd02SGreg Roach        );
1416fcafd02SGreg Roach
14205babb96SGreg Roach        $great = static fn (int $n, string $prefix, string $suffix): array => $genitive(
1436fcafd02SGreg Roach            $prefix . ($n > 3 ? 'great ×' . $n . ' ' : str_repeat('great-', $n)) . $suffix
1446fcafd02SGreg Roach        );
1456fcafd02SGreg Roach
1466fcafd02SGreg Roach        return [
1476fcafd02SGreg Roach            // Adopted
1486fcafd02SGreg Roach            Relationship::fixed('adoptive-mother', 'adoptive-mother’s %s')->adoptive()->mother(),
1496fcafd02SGreg Roach            Relationship::fixed('adoptive-father', 'adoptive-father’s %s')->adoptive()->father(),
1506fcafd02SGreg Roach            Relationship::fixed('adoptive-parent', 'adoptive-parent’s %s')->adoptive()->parent(),
1516fcafd02SGreg Roach            Relationship::fixed('adopted-daughter', 'adopted-daughter’s %s')->adopted()->daughter(),
1526fcafd02SGreg Roach            Relationship::fixed('adopted-son', 'adopted-son’s %s')->adopted()->son(),
1536fcafd02SGreg Roach            Relationship::fixed('adopted-child', 'adopted-child’s %s')->adopted()->child(),
1546fcafd02SGreg Roach            // Fostered
1556fcafd02SGreg Roach            Relationship::fixed('foster-mother', 'foster-mother’s %s')->fostering()->mother(),
1566fcafd02SGreg Roach            Relationship::fixed('foster-father', 'foster-father’s %s')->fostering()->father(),
1576fcafd02SGreg Roach            Relationship::fixed('foster-parent', 'foster-parent’s %s')->fostering()->parent(),
1586fcafd02SGreg Roach            Relationship::fixed('foster-daughter', 'foster-daughter’s %s')->fostered()->daughter(),
1596fcafd02SGreg Roach            Relationship::fixed('foster-son', 'foster-son’s %s')->fostered()->son(),
1606fcafd02SGreg Roach            Relationship::fixed('foster-child', 'foster-child’s %s')->fostered()->child(),
1616fcafd02SGreg Roach            // Parents
1626fcafd02SGreg Roach            Relationship::fixed('mother', 'mother’s %s')->mother(),
1636fcafd02SGreg Roach            Relationship::fixed('father', 'father’s %s')->father(),
1646fcafd02SGreg Roach            Relationship::fixed('parent', 'parent’s %s')->parent(),
1656fcafd02SGreg Roach            // Children
1666fcafd02SGreg Roach            Relationship::fixed('daughter', 'daughter’s %s')->daughter(),
1676fcafd02SGreg Roach            Relationship::fixed('son', 'son’s %s')->son(),
1686fcafd02SGreg Roach            Relationship::fixed('child', 'child’s %s')->child(),
1696fcafd02SGreg Roach            // Siblings
1706fcafd02SGreg Roach            Relationship::fixed('twin sister', 'twin sister’s %s')->twin()->sister(),
1716fcafd02SGreg Roach            Relationship::fixed('twin brother', 'twin brother’s %s')->twin()->brother(),
1726fcafd02SGreg Roach            Relationship::fixed('twin sibling', 'twin sibling’s %s')->twin()->sibling(),
1736fcafd02SGreg Roach            Relationship::fixed('elder sister', 'elder sister’s %s')->older()->sister(),
1746fcafd02SGreg Roach            Relationship::fixed('elder brother', 'elder brother’s %s')->older()->brother(),
1756fcafd02SGreg Roach            Relationship::fixed('elder sibling', 'elder sibling’s %s')->older()->sibling(),
1766fcafd02SGreg Roach            Relationship::fixed('younger sister', 'younger sister’s %s')->younger()->sister(),
1776fcafd02SGreg Roach            Relationship::fixed('younger brother', 'younger brother’s %s')->younger()->brother(),
1786fcafd02SGreg Roach            Relationship::fixed('younger sibling', 'younger sibling’s %s')->younger()->sibling(),
1796fcafd02SGreg Roach            Relationship::fixed('sister', 'sister’s %s')->sister(),
1806fcafd02SGreg Roach            Relationship::fixed('brother', 'brother’s %s')->brother(),
1816fcafd02SGreg Roach            Relationship::fixed('sibling', 'sibling’s %s')->sibling(),
182d8a5ab6eSJonathan Jaubart            // Half-siblings
183d8a5ab6eSJonathan Jaubart            Relationship::fixed('half-sister', 'half-sister’s %s')->parent()->daughter(),
184d8a5ab6eSJonathan Jaubart            Relationship::fixed('half-brother', 'half-brother’s %s')->parent()->son(),
185d8a5ab6eSJonathan Jaubart            Relationship::fixed('half-sibling', 'half-sibling’s %s')->parent()->child(),
186d8a5ab6eSJonathan Jaubart            // Stepfamily
187d8a5ab6eSJonathan Jaubart            Relationship::fixed('stepmother', 'stepmother’s %s')->parent()->wife(),
188d8a5ab6eSJonathan Jaubart            Relationship::fixed('stepfather', 'stepfather’s %s')->parent()->husband(),
189d8a5ab6eSJonathan Jaubart            Relationship::fixed('stepparent', 'stepparent’s %s')->parent()->married()->spouse(),
190d8a5ab6eSJonathan Jaubart            Relationship::fixed('stepdaughter', 'stepdaughter’s %s')->married()->spouse()->daughter(),
191d8a5ab6eSJonathan Jaubart            Relationship::fixed('stepson', 'stepson’s %s')->married()->spouse()->son(),
192d8a5ab6eSJonathan Jaubart            Relationship::fixed('stepchild', 'stepchild’s %s')->married()->spouse()->child(),
193d8a5ab6eSJonathan Jaubart            Relationship::fixed('stepsister', 'stepsister’s %s')->parent()->spouse()->daughter(),
194d8a5ab6eSJonathan Jaubart            Relationship::fixed('stepbrother', 'stepbrother’s %s')->parent()->spouse()->son(),
195d8a5ab6eSJonathan Jaubart            Relationship::fixed('stepsibling', 'stepsibling’s %s')->parent()->spouse()->child(),
1966fcafd02SGreg Roach            // Partners
1976fcafd02SGreg Roach            Relationship::fixed('ex-wife', 'ex-wife’s %s')->divorced()->partner()->female(),
1986fcafd02SGreg Roach            Relationship::fixed('ex-husband', 'ex-husband’s %s')->divorced()->partner()->male(),
1996fcafd02SGreg Roach            Relationship::fixed('ex-spouse', 'ex-spouse’s %s')->divorced()->partner(),
2006fcafd02SGreg Roach            Relationship::fixed('fiancée', 'fiancée’s %s')->engaged()->partner()->female(),
2016fcafd02SGreg Roach            Relationship::fixed('fiancé', 'fiancé’s %s')->engaged()->partner()->male(),
2026fcafd02SGreg Roach            Relationship::fixed('wife', 'wife’s %s')->wife(),
2036fcafd02SGreg Roach            Relationship::fixed('husband', 'husband’s %s')->husband(),
2046fcafd02SGreg Roach            Relationship::fixed('spouse', 'spouse’s %s')->spouse(),
2056fcafd02SGreg Roach            Relationship::fixed('partner', 'partner’s %s')->partner(),
2066fcafd02SGreg Roach            // In-laws
2076fcafd02SGreg Roach            Relationship::fixed('mother-in-law', 'mother-in-law’s %s')->married()->spouse()->mother(),
2086fcafd02SGreg Roach            Relationship::fixed('father-in-law', 'father-in-law’s %s')->married()->spouse()->father(),
2096fcafd02SGreg Roach            Relationship::fixed('parent-in-law', 'parent-in-law’s %s')->married()->spouse()->parent(),
2106fcafd02SGreg Roach            Relationship::fixed('daughter-in-law', 'daughter-in-law’s %s')->child()->wife(),
2116fcafd02SGreg Roach            Relationship::fixed('son-in-law', 'son-in-law’s %s')->child()->husband(),
2126fcafd02SGreg Roach            Relationship::fixed('child-in-law', 'child-in-law’s %s')->child()->married()->spouse(),
2136fcafd02SGreg Roach            Relationship::fixed('sister-in-law', 'sister-in-law’s %s')->sibling()->spouse()->sister(),
2146fcafd02SGreg Roach            Relationship::fixed('brother-in-law', 'brother-in-law’s %s')->sibling()->spouse()->brother(),
2156fcafd02SGreg Roach            Relationship::fixed('sibling-in-law', 'sibling-in-law’s %s')->sibling()->spouse()->sibling(),
2166fcafd02SGreg Roach            Relationship::fixed('sister-in-law', 'sister-in-law’s %s')->spouse()->sister(),
2176fcafd02SGreg Roach            Relationship::fixed('brother-in-law', 'brother-in-law’s %s')->spouse()->brother(),
2186fcafd02SGreg Roach            Relationship::fixed('sibling-in-law', 'sibling-in-law’s %s')->spouse()->sibling(),
2196fcafd02SGreg Roach            Relationship::fixed('sister-in-law', 'sister-in-law’s %s')->sibling()->wife(),
2206fcafd02SGreg Roach            Relationship::fixed('brother-in-law', 'brother-in-law’s %s')->sibling()->husband(),
2216fcafd02SGreg Roach            Relationship::fixed('sibling-in-law', 'sibling-in-law’s %s')->sibling()->spouse(),
2226fcafd02SGreg Roach            // Grandparents
2236fcafd02SGreg Roach            Relationship::fixed('maternal-grandmother', 'maternal-grandmother’s %s')->mother()->mother(),
2246fcafd02SGreg Roach            Relationship::fixed('maternal-grandfather', 'maternal-grandfather’s %s')->mother()->father(),
2256fcafd02SGreg Roach            Relationship::fixed('maternal-grandparent', 'maternal-grandfather’s %s')->mother()->parent(),
2266fcafd02SGreg Roach            Relationship::fixed('paternal-grandmother', 'paternal-grandmother’s %s')->father()->mother(),
2276fcafd02SGreg Roach            Relationship::fixed('paternal-grandfather', 'paternal-grandfather’s %s')->father()->father(),
2286fcafd02SGreg Roach            Relationship::fixed('paternal-grandparent', 'paternal-grandfather’s %s')->father()->parent(),
2296fcafd02SGreg Roach            Relationship::fixed('grandmother', 'grandmother’s %s')->parent()->mother(),
2306fcafd02SGreg Roach            Relationship::fixed('grandfather', 'grandfather’s %s')->parent()->father(),
2316fcafd02SGreg Roach            Relationship::fixed('grandparent', 'grandparent’s %s')->parent()->parent(),
2326fcafd02SGreg Roach            // Grandchildren
2336fcafd02SGreg Roach            Relationship::fixed('granddaughter', 'granddaughter’s %s')->child()->daughter(),
2346fcafd02SGreg Roach            Relationship::fixed('grandson', 'grandson’s %s')->child()->son(),
2356fcafd02SGreg Roach            Relationship::fixed('grandchild', 'grandchild’s %s')->child()->child(),
2366fcafd02SGreg Roach            // Relationships with dynamically generated names
2376b2cb23eSGreg Roach            Relationship::dynamic(static fn (int $n) => $great($n - 1, '', 'aunt'))->ancestor()->sister(),
2386b2cb23eSGreg Roach            Relationship::dynamic(static fn (int $n) => $great($n - 1, '', 'aunt'))->ancestor()->sibling()->wife(),
2396b2cb23eSGreg Roach            Relationship::dynamic(static fn (int $n) => $great($n - 1, '', 'uncle'))->ancestor()->brother(),
2406b2cb23eSGreg Roach            Relationship::dynamic(static fn (int $n) => $great($n - 1, '', 'uncle'))->ancestor()->sibling()->husband(),
2416b2cb23eSGreg Roach            Relationship::dynamic(static fn (int $n) => $great($n - 1, '', 'niece'))->sibling()->descendant()->female(),
2426b2cb23eSGreg Roach            Relationship::dynamic(static fn (int $n) => $great($n - 1, '', 'niece'))->married()->spouse()->sibling()->descendant()->female(),
2436b2cb23eSGreg Roach            Relationship::dynamic(static fn (int $n) => $great($n - 1, '', 'nephew'))->sibling()->descendant()->male(),
2446b2cb23eSGreg Roach            Relationship::dynamic(static fn (int $n) => $great($n - 1, '', 'nephew'))->married()->spouse()->sibling()->descendant()->male(),
24598ebe5e4SGreg Roach            Relationship::dynamic(static fn (int $n) => $great($n - 1, 'maternal ', 'grandmother'))->mother()->ancestor()->female(),
2466b2cb23eSGreg Roach            Relationship::dynamic(static fn (int $n) => $great($n - 1, 'maternal ', 'grandfather'))->mother()->ancestor()->male(),
2476b2cb23eSGreg Roach            Relationship::dynamic(static fn (int $n) => $great($n - 1, 'paternal ', 'grandmother'))->father()->ancestor()->female(),
2486b2cb23eSGreg Roach            Relationship::dynamic(static fn (int $n) => $great($n - 1, 'paternal ', 'grandfather'))->father()->ancestor()->male(),
2496b2cb23eSGreg Roach            Relationship::dynamic(static fn (int $n) => $great($n - 1, '', 'grandparent'))->ancestor(),
2506b2cb23eSGreg Roach            Relationship::dynamic(static fn (int $n) => $great($n - 2, '', 'granddaughter'))->descendant()->female(),
2516b2cb23eSGreg Roach            Relationship::dynamic(static fn (int $n) => $great($n - 2, '', 'grandson'))->descendant()->male(),
2526b2cb23eSGreg Roach            Relationship::dynamic(static fn (int $n) => $great($n - 2, '', 'grandchild'))->descendant(),
2536fcafd02SGreg Roach            Relationship::dynamic($cousin)->ancestor()->sibling()->descendant(),
2546fcafd02SGreg Roach        ];
2556fcafd02SGreg Roach    }
25602086832SGreg Roach}
257