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