diff options
author | Minteck <contact@minteck.org> | 2022-08-26 22:29:23 +0200 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2022-08-26 22:29:23 +0200 |
commit | 09bd0164ebc020a54b944b7326dcba496fb5d82c (patch) | |
tree | 0c5e765e627ecc94e534ccb6e2bc83917d58dc4c /includes/pronouns.php | |
parent | a2df9a69dcc14cb70118cda2ded499055e7ee358 (diff) | |
download | pluralconnect-09bd0164ebc020a54b944b7326dcba496fb5d82c.tar.gz pluralconnect-09bd0164ebc020a54b944b7326dcba496fb5d82c.tar.bz2 pluralconnect-09bd0164ebc020a54b944b7326dcba496fb5d82c.zip |
idk when was the last commit so I'm making a new one - Violet Dawn
Diffstat (limited to 'includes/pronouns.php')
-rw-r--r-- | includes/pronouns.php | 56 |
1 files changed, 45 insertions, 11 deletions
diff --git a/includes/pronouns.php b/includes/pronouns.php index 5f79dd3..6ab2487 100644 --- a/includes/pronouns.php +++ b/includes/pronouns.php @@ -3,6 +3,7 @@ $pronounsSets = [ "pony" => [ "gender" => "ponygender", + "gender:fr" => "poneygenre", "object" => "pony", "person" => "pony", "possessive_det" => "pony's", @@ -14,6 +15,7 @@ $pronounsSets = [ ], "she" => [ "gender" => "female", + "gender:fr" => "fille", "object" => "her", "person" => "girl", "possessive_det" => "her", @@ -25,6 +27,7 @@ $pronounsSets = [ ], "he" => [ "gender" => "male", + "gender:fr" => "garçon", "object" => "him", "person" => "boy", "possessive_det" => "his", @@ -36,6 +39,7 @@ $pronounsSets = [ ], "it" => [ "gender" => "agender", + "gender:fr" => "agenre", "object" => "it", "person" => "person", "possessive_det" => "its", @@ -47,6 +51,7 @@ $pronounsSets = [ ], "they" => [ "gender" => "non binary", + "gender:fr" => "non binaire", "object" => "them", "person" => "person", "possessive_det" => "their", @@ -58,6 +63,8 @@ $pronounsSets = [ ] ]; +$pronounGetCount = 0; + $possibilitiesPerSet = []; foreach ($pronounsSets as $name => $set) { if (!isset($possibilitiesPerSet[$name])) $possibilitiesPerSet[$name] = []; @@ -80,9 +87,9 @@ function getSetFromValue(string $value) { return null; } -function getPronounsFromMark(string $mark = null): array { - if (!isset($mark)) { - return []; +function getPronounsFromMark(?string $mark = null): array { + if (!isset($mark) || trim($mark) === "") { + return ["they"]; } else { $parts = array_unique(array_map(function ($i) { return getSetFromValue($i); @@ -94,22 +101,49 @@ function getPronounsFromMark(string $mark = null): array { function getMemberPronouns(?string $pronouns): ?array { global $pronounsSets; $list = getPronounsFromMark($pronouns); - return $pronounsSets[$list[count($list) - 1]] ?? $pronounsSets["she"]; + return $pronounsSets[$list[array_rand($list)]] ?? $pronounsSets["she"]; } -function getGenderFromPronoun(string $pronoun) { +function getGenderFromPronoun(string $pronoun, bool $french = false) { global $pronounsSets; $set = getPronounsFromMark($pronoun)[0]; - return $pronounsSets[$set]["gender"]; + + if ($french) { + return ($pronounsSets[$set] ?? $pronounsSets["they"])["gender:fr"]; + } else { + return ($pronounsSets[$set] ?? $pronounsSets["they"])["gender"]; + } } -function getTooltipsFromMark(string $mark = null): ?string { +function pronounInFrench(string $pronoun): string { + return match ($pronoun) { + "she" => "elle", + "her" => "elle", + "he" => "il", + "him" => "lui", + "they" => "iel", + "them" => "iel", + "it" => "iel", + "its" => "iel", + "pony" => "poney", + "pony's" => "à poney", + "ponys" => "à poney", + default => $pronoun, + }; +} + +function getTooltipsFromMark(string $mark = null, bool $french = false): ?string { if (!isset($mark)) { return null; } else { - return implode("/", array_map(function ($i) { - global $pronounsSets; - return "<span title='" . ucfirst(getGenderFromPronoun($i)) . "' data-bs-toggle='tooltip'>" . $i . "</span>"; - }, explode("/", $mark))); + if ($french) { + return implode("/", array_map(function ($i) { + return "<span title='" . ucfirst(getGenderFromPronoun($i, true)) . "' data-bs-toggle='tooltip'>" . pronounInFrench($i) . "</span>"; + }, explode("/", $mark))); + } else { + return implode("/", array_map(function ($i) { + return "<span title='" . ucfirst(getGenderFromPronoun($i, false)) . "' data-bs-toggle='tooltip'>" . $i . "</span>"; + }, explode("/", $mark))); + } } }
\ No newline at end of file |