From 2f48f4ca8be89aa5156078f0715a788fbe1061c1 Mon Sep 17 00:00:00 2001 From: Andrea Vos Date: Thu, 19 Aug 2021 17:56:21 +0200 Subject: [PATCH] [de][pronouns] make slashes work --- locale/de/config.suml | 2 +- src/buildPronoun.js | 39 ++++++++++++++++++++++----------------- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/locale/de/config.suml b/locale/de/config.suml index 05e178084..d803f7d5f 100644 --- a/locale/de/config.suml +++ b/locale/de/config.suml @@ -15,7 +15,7 @@ pronouns: examples: ['er&sie', 'er&dey', 'sie&xier'] null: false emoji: false - slashes: true + slashes: ['pronoun_n', 'possessive', 'pronoun_d', 'pronoun_a'] avoiding: false others: 'Andere Pronomen' diff --git a/src/buildPronoun.js b/src/buildPronoun.js index 658a881df..4cc57201d 100644 --- a/src/buildPronoun.js +++ b/src/buildPronoun.js @@ -72,23 +72,28 @@ export const buildPronoun = (pronouns, path) => { } const p = path.split('/').filter(s => !!s); - if (!pronoun && process.env.CONFIG.pronouns.slashes !== false && p.length === MORPHEMES.length) { - pronoun = new Pronoun( - `${p[0]}/${p[1]}`, - '', - false, - buildDict(function*() { - let i = 0; - for (let m of MORPHEMES) { - yield [m, p[i++]]; - } - }), - [ p[p.length - 1].endsWith('selves') ], // TODO English specific, extract somewhere - [ false ], - [], - '__generator__', - false, - ) + 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( + `${p[0]}/${p[1]}`, + '', + false, + buildDict(function*() { + for (let m of MORPHEMES) { + const index = slashMorphemes.indexOf(m) + yield [m, index === -1 ? '' : p[index]]; + } + }), + [ p[p.length - 1].endsWith('selves') ], // TODO English specific, extract somewhere + [ false ], + [], + '__generator__', + false, + ) + } } return pronoun;