[de][pronouns] make slashes work

This commit is contained in:
Andrea Vos 2021-08-19 17:56:21 +02:00
parent af1d94dc36
commit 2f48f4ca8b
2 changed files with 23 additions and 18 deletions

View File

@ -15,7 +15,7 @@ pronouns:
examples: ['er&sie', 'er&dey', 'sie&xier'] examples: ['er&sie', 'er&dey', 'sie&xier']
null: false null: false
emoji: false emoji: false
slashes: true slashes: ['pronoun_n', 'possessive', 'pronoun_d', 'pronoun_a']
avoiding: false avoiding: false
others: 'Andere Pronomen' others: 'Andere Pronomen'

View File

@ -72,15 +72,19 @@ export const buildPronoun = (pronouns, path) => {
} }
const p = path.split('/').filter(s => !!s); const p = path.split('/').filter(s => !!s);
if (!pronoun && process.env.CONFIG.pronouns.slashes !== false && p.length === MORPHEMES.length) { if (!pronoun && process.env.CONFIG.pronouns.slashes !== false) {
const slashMorphemes = process.env.CONFIG.pronouns.slashes === true
? MORPHEMES
: process.env.CONFIG.pronouns.slashes;
if (p.length === slashMorphemes.length) {
pronoun = new Pronoun( pronoun = new Pronoun(
`${p[0]}/${p[1]}`, `${p[0]}/${p[1]}`,
'', '',
false, false,
buildDict(function*() { buildDict(function*() {
let i = 0;
for (let m of MORPHEMES) { for (let m of MORPHEMES) {
yield [m, p[i++]]; const index = slashMorphemes.indexOf(m)
yield [m, index === -1 ? '' : p[index]];
} }
}), }),
[ p[p.length - 1].endsWith('selves') ], // TODO English specific, extract somewhere [ p[p.length - 1].endsWith('selves') ], // TODO English specific, extract somewhere
@ -90,6 +94,7 @@ export const buildPronoun = (pronouns, path) => {
false, false,
) )
} }
}
return pronoun; return pronoun;
} }