From e207d11d83d3731e54c2358a6cc9d189a95315cd Mon Sep 17 00:00:00 2001 From: Colin Rotherham Date: Wed, 9 Nov 2022 18:21:10 +0000 Subject: [PATCH] Ensure JSDoc plural form `other` is optional (with caveats) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See: https://github.com/alphagov/govuk-frontend/pull/2921 Whilst `other` is required in English and is used as a fallback, it won’t be in all locales --- .../components/character-count/character-count.unit.test.mjs | 4 +--- src/govuk/i18n.mjs | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/govuk/components/character-count/character-count.unit.test.mjs b/src/govuk/components/character-count/character-count.unit.test.mjs index 68ea0b59d4..e172f2a0ed 100644 --- a/src/govuk/components/character-count/character-count.unit.test.mjs +++ b/src/govuk/components/character-count/character-count.unit.test.mjs @@ -92,13 +92,11 @@ describe('CharacterCount', () => { const component = new CharacterCount($div, { i18n: { charactersUnderLimit: { - one: 'Different custom text. Count: %{count}', - other: 'Different custom text. Count: %{count}' + one: 'Different custom text. Count: %{count}' } } }) expect(component.formatCountMessage(1, 'characters')).toEqual('Custom text. Count: 1') - expect(component.formatCountMessage(10, 'characters')).toEqual('Different custom text. Count: 10') // Other keys remain untouched expect(component.formatCountMessage(-10, 'characters')).toEqual('You have 10 characters too many') expect(component.formatCountMessage(0, 'characters')).toEqual('You have 0 characters remaining') diff --git a/src/govuk/i18n.mjs b/src/govuk/i18n.mjs index 02c3898736..68e6d54143 100644 --- a/src/govuk/i18n.mjs +++ b/src/govuk/i18n.mjs @@ -372,7 +372,7 @@ I18n.pluralRules = { * translations to a component's constructor * * @typedef {object} TranslationPluralised - * @property {Translation} other - General plural form + * @property {Translation} [other] - General plural form * @property {Translation} [zero] - Plural form used with 0 * @property {Translation} [one] - Plural form used with 1 * @property {Translation} [two] - Plural form used with 2