Skip to content

Commit

Permalink
Merge 98d822c into 82e7802
Browse files Browse the repository at this point in the history
  • Loading branch information
jon48 committed Apr 20, 2021
2 parents 82e7802 + 98d822c commit 51d0435
Show file tree
Hide file tree
Showing 5 changed files with 342 additions and 47 deletions.
16 changes: 15 additions & 1 deletion app/Module/LanguageEnglishUnitedStates.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,20 @@ public function relationships(): array
Relationship::fixed('sister', 'sister’s %s')->sister(),
Relationship::fixed('brother', 'brother’s %s')->brother(),
Relationship::fixed('sibling', 'sibling’s %s')->sibling(),
// Half-siblings
Relationship::fixed('half-sister', 'half-sister’s %s')->parent()->daughter(),
Relationship::fixed('half-brother', 'half-brother’s %s')->parent()->son(),
Relationship::fixed('half-sibling', 'half-sibling’s %s')->parent()->child(),
// Stepfamily
Relationship::fixed('stepmother', 'stepmother’s %s')->parent()->wife(),
Relationship::fixed('stepfather', 'stepfather’s %s')->parent()->husband(),
Relationship::fixed('stepparent', 'stepparent’s %s')->parent()->married()->spouse(),
Relationship::fixed('stepdaughter', 'stepdaughter’s %s')->married()->spouse()->daughter(),
Relationship::fixed('stepson', 'stepson’s %s')->married()->spouse()->son(),
Relationship::fixed('stepchild', 'stepchild’s %s')->married()->spouse()->child(),
Relationship::fixed('stepsister', 'stepsister’s %s')->parent()->spouse()->daughter(),
Relationship::fixed('stepbrother', 'stepbrother’s %s')->parent()->spouse()->son(),
Relationship::fixed('stepsibling', 'stepsibling’s %s')->parent()->spouse()->child(),
// Partners
Relationship::fixed('ex-wife', 'ex-wife’s %s')->divorced()->partner()->female(),
Relationship::fixed('ex-husband', 'ex-husband’s %s')->divorced()->partner()->male(),
Expand Down Expand Up @@ -211,7 +225,7 @@ public function relationships(): array
Relationship::dynamic(fn (int $n) => $great($n - 1, '', 'aunt'))->ancestor()->sibling()->wife(),
Relationship::dynamic(fn (int $n) => $great($n - 1, '', 'uncle'))->ancestor()->brother(),
Relationship::dynamic(fn (int $n) => $great($n - 1, '', 'uncle'))->ancestor()->sibling()->husband(),
Relationship::dynamic(fn (int $n) => $great($n - 1, '', 'niece'))->descendant()->sister(),
Relationship::dynamic(fn (int $n) => $great($n - 1, '', 'niece'))->sibling()->descendant()->female(),
Relationship::dynamic(fn (int $n) => $great($n - 1, '', 'niece'))->married()->spouse()->sibling()->descendant()->female(),
Relationship::dynamic(fn (int $n) => $great($n - 1, '', 'nephew'))->sibling()->descendant()->male(),
Relationship::dynamic(fn (int $n) => $great($n - 1, '', 'nephew'))->married()->spouse()->sibling()->descendant()->male(),
Expand Down
166 changes: 166 additions & 0 deletions app/Module/LanguageFrench.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

use Fisharebest\Localization\Locale\LocaleFr;
use Fisharebest\Localization\Locale\LocaleInterface;
use Fisharebest\Webtrees\Relationship;

/**
* Class LanguageFrench.
Expand All @@ -29,11 +30,176 @@ class LanguageFrench extends AbstractModule implements ModuleLanguageInterface
{
use ModuleLanguageTrait;

protected const SYMMETRIC_COUSINS = [
1 => [
'F' => ['cousine germaine', '$s de la cousine germaine'],
'M' => ['cousin germain', '$s du cousin germain'],
'U' => ['cousin germain', '%s du cousin germain' ]
],
2 => [
'F' => ['cousine issue de germain', '$s de la cousine issue de germain'],
'M' => ['cousin issu de germain', '$s du cousin issu de germain'],
'U' => ['cousin issu de germain', '%s du cousin issu de germain' ]
]
];

protected const ASYMMETRIC_COUSINS = [
1 => [
'F' => ['down', 'petite-', 'cousine', 'de la ', 'de la '],
'M' => ['down', 'petit-', 'cousin', 'du ', 'du '],
'U' => ['down', 'petit-', 'cousin', 'du ', 'du ']
],
-1 => [
'F' => ['up', 'grand-', 'cousine', 'de la ', 'de la '],
'M' => ['up', 'grand-', 'cousin', 'du ', 'du '],
'U' => ['up', 'grand-', 'cousin', 'du ', 'du ']
],
];

/**
* @return LocaleInterface
*/
public function locale(): LocaleInterface
{
return new LocaleFr();
}

public function relationships(): array
{
$genitive = fn (string $s, string $genitive_link): array => [$s, '%s ' . $genitive_link . $s];

$great = fn (int $n, string $suffix, string $genitive_link): array => $genitive(
($n > 2 ? 'arrière-(x' . $n . ')-' : str_repeat('arrière-', max($n, 0))) . $suffix,
$n === 0 ? $genitive_link : 'de l’'
);

$compoundgreat =
fn (int $n, string $first_level, string $suffix, string $genitive_none, string $genitive_first): array =>
$great($n - 1, ($n > 0 ? $first_level : '' ) . $suffix, $n === 0 ? $genitive_none : $genitive_first);

$symmetricCousin = fn(int $n, string $sex): array => self::SYMMETRIC_COUSINS[$n][$sex] ?? $genitive(
$sex === 'F' ? 'cousine au ' . $n . '<sup>e</sup> degré' : 'cousin au ' . $n . '<sup>e</sup> degré',
$sex === 'F' ? 'de la ' : 'du '
);

$asymmetricCousin =
function (int $up, int $down, string $sex) use ($symmetricCousin, $compoundgreat, $genitive): array {
if ($up === $down) {
return $symmetricCousin($up, $sex);
}
$fixed = self::ASYMMETRIC_COUSINS[$up][$sex] ?? self::ASYMMETRIC_COUSINS[-$down][$sex] ?? null;
if ($fixed !== null) {
$fixed[0] = $fixed[0] === 'up' ? $up - 1 : $down - 1;
return $compoundgreat(...$fixed);
}
return $genitive(
$sex === 'F' ?
'cousine du ' . $down . '<sup>e</sup> au ' . $up . '<sup>e</sup> degré' :
'cousin du ' . $down . '<sup>e</sup> au ' . $up . '<sup>e</sup> degré',
$sex === 'F' ? 'de la ' : 'du '
);
};

return [
// Adopted
Relationship::fixed('mère adoptive', '%s de la mère adoptive')->adoptive()->mother(),
Relationship::fixed('père adoptif', '%s du père adoptif')->adoptive()->father(),
Relationship::fixed('parent adoptif', '%s du parent adoptif')->adoptive()->parent(),
Relationship::fixed('fille adoptive', '%s de la fille adoptive')->adopted()->daughter(),
Relationship::fixed('fils adoptif', '%s du fils adoptif')->adopted()->son(),
Relationship::fixed('enfant adoptif', '%s de l’enfant adoptif')->adopted()->child(),
// Fostered
Relationship::fixed('mère d’accueil', '%s de la mère d’acceuil')->fostering()->mother(),
Relationship::fixed('père d’accueil', '%s du père d’acceuil')->fostering()->father(),
Relationship::fixed('parent d’accueil', '%s du parent d’acceuil')->fostering()->parent(),
Relationship::fixed('fille accueillie', '%s de la fille accueillie')->fostered()->daughter(),
Relationship::fixed('fils accueilli', '%s du fils accueilli')->fostered()->son(),
Relationship::fixed('enfant accueilli', '%s de l’enfant accueilli')->fostered()->child(),
// Parents
Relationship::fixed('mère', '%s de la mère')->mother(),
Relationship::fixed('père', '%s du père')->father(),
Relationship::fixed('parent', '%s du parent')->parent(),
// Children
Relationship::fixed('fille', '%s de la fille')->daughter(),
Relationship::fixed('fils', '%s du fils')->son(),
Relationship::fixed('enfant', '%s de l’enfant')->child(),
// Siblings
Relationship::fixed('sœur jumelle', '%s de la sœur jumelle')->twin()->sister(),
Relationship::fixed('frère jumeau', '%s du frère jumeau')->twin()->brother(),
Relationship::fixed('jumeau', '%s du jumeau')->twin()->sibling(),
Relationship::fixed('grande sœur', '%s de la grande sœur')->older()->sister(),
Relationship::fixed('grand frère', '%s du grand frère')->older()->brother(),
Relationship::fixed('grand frère/sœur', '%s du grand frère/sœur')->older()->sibling(),
Relationship::fixed('petite sœur', '%s de la petite sœur')->younger()->sister(),
Relationship::fixed('petit frère', '%s du petit-frère')->younger()->brother(),
Relationship::fixed('petit frère/sœur', '%s du petit frère/sœur')->younger()->sibling(),
Relationship::fixed('sœur', '%s de la sœur')->sister(),
Relationship::fixed('frère', '%s du frère')->brother(),
Relationship::fixed('frère/sœur', '%s du frère/sœur')->sibling(),
// Half-family
Relationship::fixed('demi-sœur', '%s de la demi-sœur')->parent()->daughter(),
Relationship::fixed('demi-frère', '%s du demi-frère')->parent()->son(),
Relationship::fixed('demi-frère/sœur', '%s du demi-frère/sœur')->parent()->child(),
// Stepfamily
Relationship::fixed('belle-mère', '%s de la belle-mère')->parent()->wife(),
Relationship::fixed('beau-père', '%s du beau-père')->parent()->husband(),
Relationship::fixed('beau-parent', '%s du beau-parent')->parent()->married()->spouse(),
Relationship::fixed('belle-fille', '%s de la belle-fille')->married()->spouse()->daughter(),
Relationship::fixed('beau-fils', '%s du beau-fils')->married()->spouse()->son(),
Relationship::fixed('beau-fils/fille', '%s du beau-fils/fille')->married()->spouse()->child(),
Relationship::fixed('quasi-sœur', '%s de la quasi-sœur')->parent()->spouse()->daughter(),
Relationship::fixed('quasi-frère', '%s du quasi-frère')->parent()->spouse()->son(),
Relationship::fixed('quasi-frère/sœur', '%s du quasi-frère/sœur')->parent()->spouse()->child(),
// Partners
Relationship::fixed('ex-épouse', '%s de l’ex-épouse')->divorced()->partner()->female(),
Relationship::fixed('ex-époux', '%s de l’ex-époux')->divorced()->partner()->male(),
Relationship::fixed('ex-conjoint', '%s de l’ex-conjoint')->divorced()->partner(),
Relationship::fixed('fiancée', '%s de la fiancée')->engaged()->partner()->female(),
Relationship::fixed('fiancé', '%s du fiancé')->engaged()->partner()->male(),
Relationship::fixed('épouse', '%s de l’épouse')->wife(),
Relationship::fixed('époux', '%s de l’époux')->husband(),
Relationship::fixed('époux', '%s de l’époux')->spouse(),
Relationship::fixed('conjoint', '%s du conjoint')->partner(),
// In-laws
Relationship::fixed('belle-mère', '%s de la belle-mère')->married()->spouse()->mother(),
Relationship::fixed('beau-père', '%s du beau-père')->married()->spouse()->father(),
Relationship::fixed('beau-parent', '%s du beau-parent')->married()->spouse()->parent(),
Relationship::fixed('belle-fille', '%s de la belle-fille')->child()->wife(),
Relationship::fixed('beau-fils', '%s du beau-fils')->child()->husband(),
Relationship::fixed('beau-fils/belle-fille', '%s du beau-fils/belle-fille')->child()->married()->spouse(),
Relationship::fixed('belle-sœur', '%s de la belle-sœur')->spouse()->sister(),
Relationship::fixed('beau-frère', '%s du beau-frère')->spouse()->brother(),
Relationship::fixed('beau-frère/belle-sœur', '%s du beau-frère/belle-sœur')->spouse()->sibling(),
Relationship::fixed('belle-sœur', '%s de la belle-sœur')->sibling()->wife(),
Relationship::fixed('beau-frère', '%s du beau-frère')->sibling()->husband(),
Relationship::fixed('beau-frère/belle-sœur', '%s du beau-frère/belle-sœur')->sibling()->spouse(),
// Grandparents and above
Relationship::dynamic(fn (int $n) => $great($n - 1, 'grand-mère maternelle', 'de la '))->mother()->ancestor()->female(),
Relationship::dynamic(fn (int $n) => $great($n - 1, 'grand-père maternel', 'du '))->mother()->ancestor()->male(),
Relationship::dynamic(fn (int $n) => $great($n - 1, 'grand-mère paternelle', 'de la '))->father()->ancestor()->female(),
Relationship::dynamic(fn (int $n) => $great($n - 1, 'grand-père paternel', 'du '))->father()->ancestor()->male(),
Relationship::dynamic(fn (int $n) => $great($n - 2, 'grand-mère', 'de la '))->ancestor()->female(),
Relationship::dynamic(fn (int $n) => $great($n - 2, 'grand-père', 'du '))->ancestor()->male(),
Relationship::dynamic(fn (int $n) => $great($n - 2, 'grand-parent', 'du '))->ancestor(),
// Grandchildren and below
Relationship::dynamic(fn (int $n) => $great($n - 2, 'petite-fille', 'de la '))->descendant()->female(),
Relationship::dynamic(fn (int $n) => $great($n - 2, 'petit-fils', 'du '))->descendant()->male(),
Relationship::dynamic(fn (int $n) => $great($n - 2, 'petit-enfant', 'du'))->descendant(),
// Collateral relatives
Relationship::dynamic(fn (int $n) => $compoundgreat($n - 1, 'grand-', 'tante', 'de la ', 'de la '))->ancestor()->sister(),
Relationship::dynamic(fn (int $n) => $compoundgreat($n - 1, 'grand-', 'tante par alliance', 'de la ', 'de la '))->ancestor()->sibling()->wife(),
Relationship::dynamic(fn (int $n) => $compoundgreat($n - 1, 'grand-', 'oncle', 'de l’', 'du '))->ancestor()->brother(),
Relationship::dynamic(fn (int $n) => $compoundgreat($n - 1, 'grand-', 'oncle par alliance', 'de l’', 'du '))->ancestor()->sibling()->husband(),
Relationship::dynamic(fn (int $n) => $compoundgreat($n - 1, 'petite-', 'nièce', 'de la ', 'de la '))->sibling()->descendant()->female(),
Relationship::dynamic(fn (int $n) => $compoundgreat($n - 1, 'petite-', 'nièce par alliance', 'de la ', 'de la '))->married()->spouse()->sibling()->descendant()->female(),
Relationship::dynamic(fn (int $n) => $compoundgreat($n - 1, 'petit-', 'neveu', 'du ', 'du '))->sibling()->descendant()->male(),
Relationship::dynamic(fn (int $n) => $compoundgreat($n - 1, 'petit-', 'neveu par alliance', 'du ', 'du '))->married()->spouse()->sibling()->descendant()->male(),
// Cousins (based on canon law)
Relationship::dynamic(fn(int $n) => $symmetricCousin($n, 'F'))->symmetricCousin()->female(),
Relationship::dynamic(fn(int $n) => $symmetricCousin($n, 'M'))->symmetricCousin()->male(),
Relationship::dynamic(fn(int $up, int $down) => $asymmetricCousin($up, $down, 'F'))->asymmetricCousin()->female(),
Relationship::dynamic(fn(int $up, int $down) => $asymmetricCousin($up, $down, 'M'))->asymmetricCousin()->male(),

];
}
}
3 changes: 1 addition & 2 deletions app/Module/LanguageFrenchCanada.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@
/**
* Class LanguageFrenchCanada.
*/
class LanguageFrenchCanada extends AbstractModule implements ModuleLanguageInterface
class LanguageFrenchCanada extends LanguageFrench
{
use ModuleLanguageTrait;

/**
* Should this module be enabled when it is first installed?
Expand Down
6 changes: 3 additions & 3 deletions app/Relationship.php
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ public function older(): Relationship
$date1 = $nodes[0]->facts(['BIRT'], false, Auth::PRIV_HIDE)->map(fn (Fact $fact): Date => $fact->date())->first() ?? new Date('');
$date2 = $nodes[2]->facts(['BIRT'], false, Auth::PRIV_HIDE)->map(fn (Fact $fact): Date => $fact->date())->first() ?? new Date('');

return Date::compare($date1, $date2) < 0;
return Date::compare($date1, $date2) > 0;
}

return false;
Expand Down Expand Up @@ -491,7 +491,7 @@ public function symmetricCousin(): Relationship
}


$nodes = array_slice($nodes, 2 * $n);
$nodes = array_slice($nodes, 2 * (2 * $n + 1));
$patterns = [];
$captures[] = $n;

Expand Down Expand Up @@ -543,7 +543,7 @@ public function younger(): Relationship
$date1 = $nodes[0]->facts(['BIRT'], false, Auth::PRIV_HIDE)->map(fn (Fact $fact): Date => $fact->date())->first() ?? new Date('');
$date2 = $nodes[2]->facts(['BIRT'], false, Auth::PRIV_HIDE)->map(fn (Fact $fact): Date => $fact->date())->first() ?? new Date('');

return Date::compare($date1, $date2) > 0;
return Date::compare($date1, $date2) < 0;
}

return false;
Expand Down

0 comments on commit 51d0435

Please sign in to comment.