Skip to content

Commit

Permalink
Ensure JSDoc plural form other is optional (with caveats)
Browse files Browse the repository at this point in the history
See: #2921

Whilst `other` is required in English and is used as a fallback, it won’t be in all locales
  • Loading branch information
colinrotherham committed Nov 10, 2022
1 parent 6f9fd78 commit 0a679b8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion src/govuk/i18n.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ I18n.pluralRules = {
* translations to a component's constructor
*
* @typedef {object} TranslationPluralForms
* @property {string} other - General plural form
* @property {string} [other] - General plural form
* @property {string} [zero] - Plural form used with 0
* @property {string} [one] - Plural form used with 1
* @property {string} [two] - Plural form used with 2
Expand Down

0 comments on commit 0a679b8

Please sign in to comment.