From c8a6f24edc4ec521bdef4add94b816fbe31f0adc Mon Sep 17 00:00:00 2001 From: Andrea Vos Date: Thu, 26 Nov 2020 00:05:39 +0100 Subject: [PATCH] #114 [nouns][en] allow skipping plurals --- components/NounForm.vue | 3 ++- components/NounSubmitForm.vue | 18 +++++++++--------- locale/en/config.suml | 1 + locale/en/translations.suml | 2 +- locale/pl/config.suml | 1 + server/routes/nouns.js | 2 +- src/classes.js | 6 +++--- 7 files changed, 18 insertions(+), 15 deletions(-) diff --git a/components/NounForm.vue b/components/NounForm.vue index 51a4e8a24..a55fbf290 100644 --- a/components/NounForm.vue +++ b/components/NounForm.vue @@ -2,7 +2,7 @@
-
+
@@ -20,6 +20,7 @@ export default { props: { value: {required: true}, + required: {type: Boolean} }, data() { return { diff --git a/components/NounSubmitForm.vue b/components/NounSubmitForm.vue index 0a40394bb..b6e2ca1e0 100644 --- a/components/NounSubmitForm.vue +++ b/components/NounSubmitForm.vue @@ -57,13 +57,13 @@ nouns.pluralShort - + - + - + @@ -126,9 +126,9 @@ masc: [''], fem: [''], neutr: [''], - mascPl: [''], - femPl: [''], - neutrPl: [''], + mascPl: this.config.nouns.pluralsRequired ? [''] : [], + femPl: this.config.nouns.pluralsRequired ? [''] : [], + neutrPl: this.config.nouns.pluralsRequired ? [''] : [], base: null, }, submitting: false, @@ -149,9 +149,9 @@ masc: [''], fem: [''], neutr: [''], - mascPl: [''], - femPl: [''], - neutrPl: [''], + mascPl: this.config.nouns.pluralsRequired ? [''] : [], + femPl: this.config.nouns.pluralsRequired ? [''] : [], + neutrPl: this.config.nouns.pluralsRequired ? [''] : [], base: null, }; this.templateVisible = false; diff --git a/locale/en/config.suml b/locale/en/config.suml index 07385f0a6..c1c53efed 100644 --- a/locale/en/config.suml +++ b/locale/en/config.suml @@ -46,6 +46,7 @@ nouns: route: 'dictionary' collapsable: false plurals: true + pluralsRequired: false declension: false submit: true templates: true diff --git a/locale/en/translations.suml b/locale/en/translations.suml index 2b4197cb5..482249eb6 100644 --- a/locale/en/translations.suml +++ b/locale/en/translations.suml @@ -177,7 +177,7 @@ faq: Because addressing people in the way they want to be addressed is the basis of social relations. You wouldn't call Ashley “Samantha”, you wouldn't drop “sir”/“madam” when addressing your supervisor, etc. And there's people who don't want to be called either “{/he=he}” or “{/she=she}”. - If you don't accept that, if only shows you in bad light. + If you don't accept that, it only shows you in bad light. - > “Strange pronouns” are just a matter of getting used to. how-to-know: diff --git a/locale/pl/config.suml b/locale/pl/config.suml index 7a34bdde4..9ec829c2d 100644 --- a/locale/pl/config.suml +++ b/locale/pl/config.suml @@ -26,6 +26,7 @@ nouns: route: 'słownik' collapsable: true plurals: true + pluralsRequired: true declension: true submit: true templates: true diff --git a/server/routes/nouns.js b/server/routes/nouns.js index e65eb6839..24ce5d5e4 100644 --- a/server/routes/nouns.js +++ b/server/routes/nouns.js @@ -174,7 +174,7 @@ router.get('/nouns/:word.png', async (req, res) => { ['masc', 'fem', 'neutr'].forEach((form, column) => { let i = 0; for (let [key, symbol] of [['', '⋅'], ['Pl', '⁖']]) - noun[form + key].split('|').forEach(part => { + noun[form + key].split('|').filter(x => x.length).forEach(part => { context.fillText(symbol + ' ' + part, column * (width - 2 * padding) / 3 + padding, 244 + i * 48); i++; }); diff --git a/src/classes.js b/src/classes.js index f78059705..16dd91f0f 100644 --- a/src/classes.js +++ b/src/classes.js @@ -322,9 +322,9 @@ export class Noun { this.masc = masc.split('|'); this.fem = fem.split('|'); this.neutr = neutr.split('|'); - this.mascPl = mascPl.split('|'); - this.femPl = femPl.split('|'); - this.neutrPl = neutrPl.split('|'); + this.mascPl = mascPl ? mascPl.split('|') : []; + this.femPl = femPl ? femPl.split('|') : []; + this.neutrPl = neutrPl ? neutrPl.split('|') : []; this.approved = !!approved; this.base = base_id; }