mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-24 05:05:20 -04:00
Merge branch 'german-consider-endings-in-null-pronouns' into 'main'
Use different possessive suffixes depending on the suffix of the name in case of no pronouns See merge request PronounsPage/PronounsPage!381
This commit is contained in:
commit
d266859d2a
@ -22,7 +22,7 @@ pronouns:
|
||||
pronoun_n: '#'
|
||||
pronoun_d: '#'
|
||||
pronoun_a: '#'
|
||||
possessive: '#s'
|
||||
possessive: '#/[sxzß]$/i#’|#s'
|
||||
examples: [':Andrea', ':S']
|
||||
template: 'Öffne eines der Beispiele und ersetze einfach den Namen/Anfangsbuchstaben in der URL durch Deinen eigenen.'
|
||||
emoji: false
|
||||
|
@ -21,6 +21,23 @@ export const getPronoun = (pronouns, id) => {
|
||||
return addAliasesToPronouns(pronouns)[id];
|
||||
}
|
||||
|
||||
const conditionalKeyPlaceHolder = /#\/([^/]+)\/(\w+)?#/;
|
||||
const unconditionalKeyPlaceholder = /#/g;
|
||||
|
||||
const buildMorphemeFromTemplate = (key, template) => {
|
||||
const variants = template.split('|');
|
||||
for (const variant of variants) {
|
||||
const conditionalMatch = variant.match(conditionalKeyPlaceHolder);
|
||||
if (conditionalMatch) {
|
||||
if (key.match(new RegExp(conditionalMatch[1], conditionalMatch[2]))) {
|
||||
return variant.replace(conditionalKeyPlaceHolder, key);
|
||||
}
|
||||
} else {
|
||||
return variant.replace(unconditionalKeyPlaceholder, key);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const buildPronounFromTemplate = (key, template) => {
|
||||
return new Pronoun(
|
||||
key,
|
||||
@ -29,7 +46,7 @@ const buildPronounFromTemplate = (key, template) => {
|
||||
buildDict(function*(morphemes) {
|
||||
for (let k in morphemes) {
|
||||
if (morphemes.hasOwnProperty(k)) {
|
||||
yield [k, morphemes[k].replace(/#/g, key)];
|
||||
yield [k, buildMorphemeFromTemplate(key, morphemes[k])];
|
||||
}
|
||||
}
|
||||
}, template.morphemes),
|
||||
|
Loading…
x
Reference in New Issue
Block a user