From a787f403a56f08a35e23acc6dd9e67037b701a5b Mon Sep 17 00:00:00 2001 From: Andrea Vos Date: Thu, 3 Dec 2020 17:38:58 +0100 Subject: [PATCH] #117 slash-separated pronoun urls --- locale/en/config.suml | 1 + src/buildPronoun.js | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/locale/en/config.suml b/locale/en/config.suml index b3a3243e5..5af2c3578 100644 --- a/locale/en/config.suml +++ b/locale/en/config.suml @@ -34,6 +34,7 @@ pronouns: reflexive: '#self' examples: ['💫', '💙'] template: 'Open one of the examples and simply replace the emoji in the URL with your own.' + slashes: true avoiding: false others: 'Other pronouns' diff --git a/src/buildPronoun.js b/src/buildPronoun.js index 119524921..dfc525cd1 100644 --- a/src/buildPronoun.js +++ b/src/buildPronoun.js @@ -51,6 +51,27 @@ export const buildPronoun = (pronouns, path) => { pronoun = buildPronounFromTemplate(path.substring(1), process.env.CONFIG.pronouns.null); } + 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 ], + [], + [], + null, + false, + ) + } + return pronoun; }