From b91b2b1479dce0b96ab23b5ac5c701bf3cb60df8 Mon Sep 17 00:00:00 2001 From: Andrea Vos Date: Sun, 24 Jul 2022 18:57:52 +0200 Subject: [PATCH] sentence links --- locale/pl/config.suml | 7 +++++++ locale/pl/translations.suml | 2 ++ nuxt.config.js | 20 +++++++++++--------- routes/pronouns.vue | 10 ++++++++++ src/buildPronoun.js | 7 +++++++ 5 files changed, 37 insertions(+), 9 deletions(-) diff --git a/locale/pl/config.suml b/locale/pl/config.suml index e5fae8ae0..721ee8d93 100644 --- a/locale/pl/config.suml +++ b/locale/pl/config.suml @@ -178,6 +178,13 @@ pronouns: - 'Osoba B używa {/ona=rodzaju żeńskiego}, więc zwracając się do osoby A lub mówiąc o niej będzie używała form żeńskich.' - 'Osoba C używa {/onu=dukaizmów} wymiennie z {/ono=rodzajem neutralnym}, więc zwracając się do osoby A lub mówiąc o num będzie używała form postpłciowych bądź neutralnych.' others: 'Pozostałe formy' + sentence: + subdomains: ['moje', 'nasze'] + prefixes: ['/to'] + examples: + - 'moje.zaimki.pl/to/ono/jego' + - 'moje.zaimki.pl/to/onu&ona' + - 'nasze.zaimki.pl/to/oni/ich&one/ich' pronunciation: enabled: true diff --git a/locale/pl/translations.suml b/locale/pl/translations.suml index 60400bba0..016b63a50 100644 --- a/locale/pl/translations.suml +++ b/locale/pl/translations.suml @@ -94,6 +94,8 @@ pronouns: othersRaw: 'inne' or: 'lub' grammarTable: 'Odmiana' + sentence: + 'Oprócz domyślnych linków możesz też podlinkować do swoich zaimków tak, aby URL czytało się niemal jak zdanie, na przykład:' sources: header: 'Teksty kultury' diff --git a/nuxt.config.js b/nuxt.config.js index 908183139..6295f3055 100644 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -318,15 +318,17 @@ export default { } if (config.pronouns.enabled) { - routes.push({ path: `/${encodeURIComponent(config.pronouns.any)}`, component: resolve(__dirname, 'routes/any.vue') }); - routes.push({ path: `/${encodeURIComponent(config.pronouns.any)}::group`, component: resolve(__dirname, 'routes/any.vue') }); - if (config.pronouns.null && config.pronouns.null.routes) { - for (let route of config.pronouns.null.routes) { - routes.push({ path: '/' + encodeURIComponent(route), component: resolve(__dirname, 'routes/avoiding.vue') }); + for (let prefix of [...(config.pronouns.sentence ? config.pronouns.sentence.prefixes : []), '']) { + routes.push({ path: `${prefix}/${encodeURIComponent(config.pronouns.any)}`, component: resolve(__dirname, 'routes/any.vue') }); + routes.push({ path: `${prefix}/${encodeURIComponent(config.pronouns.any)}::group`, component: resolve(__dirname, 'routes/any.vue') }); + if (config.pronouns.null && config.pronouns.null.routes) { + for (let route of config.pronouns.null.routes) { + routes.push({ path: `${prefix}/${encodeURIComponent(route)}`, component: resolve(__dirname, 'routes/avoiding.vue') }); + } + } + if (config.pronouns.mirror) { + routes.push({ path: `${prefix}/${encodeURIComponent(config.pronouns.mirror.route)}`, component: resolve(__dirname, 'routes/mirror.vue') }); } - } - if (config.pronouns.mirror) { - routes.push({ path: '/' + encodeURIComponent(config.pronouns.mirror.route), component: resolve(__dirname, 'routes/mirror.vue') }); } } @@ -340,7 +342,7 @@ export default { routes.push({ path: '/api', component: resolve(__dirname, 'routes/api.vue') }); } - routes.push({ name: 'all', path: '*', component: resolve(__dirname, 'routes/pronoun.vue') }); + routes.push({ name: 'all', path: `*`, component: resolve(__dirname, 'routes/pronoun.vue') }); }, }, } diff --git a/routes/pronouns.vue b/routes/pronouns.vue index 61dddff8c..a52404e30 100644 --- a/routes/pronouns.vue +++ b/routes/pronouns.vue @@ -3,6 +3,16 @@
+
+ + pronouns.sentence + +
+
  • diff --git a/src/buildPronoun.js b/src/buildPronoun.js index f7d4d8d37..457dab503 100644 --- a/src/buildPronoun.js +++ b/src/buildPronoun.js @@ -48,6 +48,13 @@ export const buildPronoun = (pronouns, path) => { const config = global.config || process.env.CONFIG; + for (let prefix of config.pronouns.sentence ? config.pronouns.sentence.prefixes : []) { + if (('/' + path).startsWith(prefix + '/')) { + path = path.substring(prefix.length); + break; + } + } + const pronounsWithAliases = addAliasesToPronouns(pronouns); const pronounStr = path.split(',');