diff options
author | Minteck <contact@minteck.org> | 2022-08-21 17:31:56 +0200 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2022-08-21 17:31:56 +0200 |
commit | a2df9a69dcc14cb70118cda2ded499055e7ee358 (patch) | |
tree | 6dd283e4e9452d38bce81ddaaae49b5335755842 /includes/pronouns.php | |
parent | 84dd0735820b16b60f600284d35183d76547a71f (diff) | |
download | pluralconnect-a2df9a69dcc14cb70118cda2ded499055e7ee358.tar.gz pluralconnect-a2df9a69dcc14cb70118cda2ded499055e7ee358.tar.bz2 pluralconnect-a2df9a69dcc14cb70118cda2ded499055e7ee358.zip |
m. update
Diffstat (limited to 'includes/pronouns.php')
-rw-r--r-- | includes/pronouns.php | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/includes/pronouns.php b/includes/pronouns.php new file mode 100644 index 0000000..5f79dd3 --- /dev/null +++ b/includes/pronouns.php @@ -0,0 +1,115 @@ +<?php + +$pronounsSets = [ + "pony" => [ + "gender" => "ponygender", + "object" => "pony", + "person" => "pony", + "possessive_det" => "pony's", + "possessive_pro" => "pony's", + "reflexive" => "ponyself", + "subjective" => "pony", + "third" => true, + "color" => "warning" + ], + "she" => [ + "gender" => "female", + "object" => "her", + "person" => "girl", + "possessive_det" => "her", + "possessive_pro" => "hers", + "reflexive" => "herself", + "subjective" => "she", + "third" => true, + "color" => "success" + ], + "he" => [ + "gender" => "male", + "object" => "him", + "person" => "boy", + "possessive_det" => "his", + "possessive_pro" => "his", + "reflexive" => "himself", + "subjective" => "he", + "third" => true, + "color" => "info" + ], + "it" => [ + "gender" => "agender", + "object" => "it", + "person" => "person", + "possessive_det" => "its", + "possessive_pro" => "its", + "reflexive" => "itself", + "subjective" => "it", + "third" => true, + "color" => "light" + ], + "they" => [ + "gender" => "non binary", + "object" => "them", + "person" => "person", + "possessive_det" => "their", + "possessive_pro" => "theirs", + "reflexive" => "themself", + "subjective" => "they", + "third" => false, + "color" => "primary" + ] +]; + +$possibilitiesPerSet = []; +foreach ($pronounsSets as $name => $set) { + if (!isset($possibilitiesPerSet[$name])) $possibilitiesPerSet[$name] = []; + $possibilitiesPerSet[$name][] = $name; + + foreach ($set as $category => $value) { + if (is_string($value)) $possibilitiesPerSet[$name][] = $value; + } +} + +function getSetFromValue(string $value) { + global $possibilitiesPerSet; + + foreach ($possibilitiesPerSet as $name => $set) { + if (in_array($value, $set)) { + return $name; + } + } + + return null; +} + +function getPronounsFromMark(string $mark = null): array { + if (!isset($mark)) { + return []; + } else { + $parts = array_unique(array_map(function ($i) { + return getSetFromValue($i); + }, explode("/", $mark))); + return $parts; + } +} + +function getMemberPronouns(?string $pronouns): ?array { + global $pronounsSets; + $list = getPronounsFromMark($pronouns); + return $pronounsSets[$list[count($list) - 1]] ?? $pronounsSets["she"]; +} + +function getGenderFromPronoun(string $pronoun) { + global $pronounsSets; + $set = getPronounsFromMark($pronoun)[0]; + return $pronounsSets[$set]["gender"]; +} + +function getTooltipsFromMark(string $mark = null): ?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))); + } +}
\ No newline at end of file |