Character Count component throws error with missing plural text #2918
Labels
🐛 bug
Something isn't working the way it should (including incorrect wording in documentation)
character count
🕔 hours
A well understood issue which we expect to take less than a day to resolve.
javascript
Milestone
Description of the issue
The Character Count component is undergoing some localisation changes:
After the v4.3.1 → v4.4.0 upgrade, Character Counts might run as a different locale than intended.
This is a problem because we
throw new Error()
when the "new" locale's text can't be found:https://github.com/alphagov/govuk-frontend/blob/main/src/govuk/i18n.mjs#L49
Teams may miss this issue because the error is only thrown when approaching the character limit.
Steps to reproduce the issue
govuk-frontend@4.4.0
cy-GB
(or other locale) pageNote: This can be triggered on the Translated page
/examples/translated
by setting<html lang="cy-GB">
before the JavaScript runs. You can do this with{% set htmlLang = 'cy-GB' %}
in the Translated page templateAdded a video demonstration from @36degrees:
Error.thrown.for.missing.plural.forms.when.approaching.character.limit.mp4
Actual vs expected behaviour
Actual behaviour
Expected behaviour
govuk-frontend@4.3.1
pre-upgradeThe text was updated successfully, but these errors were encountered: