Skip to content

Localise character count component#1565

Merged
colinrotherham merged 9 commits into
mainfrom
component-character-count-localise
Oct 8, 2025
Merged

Localise character count component#1565
colinrotherham merged 9 commits into
mainfrom
component-character-count-localise

Conversation

@colinrotherham
Copy link
Copy Markdown
Contributor

@colinrotherham colinrotherham commented Sep 5, 2025

Description

This PR adds character count localisation by porting these features from GOV.UK Frontend:

Backwards compatibility has been maintained with v10.x in 6be936f

Translated examples

I've added a new Translated examples page with Welsh examples for maxlength and maxwords

Welsh character count example

Checklist

@colinrotherham colinrotherham temporarily deployed to nhsuk-frontend-pr-1565 September 5, 2025 07:54 Inactive
@colinrotherham colinrotherham force-pushed the component-config-validation branch from 71d8f2f to 415f553 Compare September 5, 2025 11:11
@colinrotherham colinrotherham changed the base branch from component-config-validation to component-form-inputs September 5, 2025 11:49
@colinrotherham colinrotherham force-pushed the component-character-count-localise branch from f7c9f07 to 9bc97af Compare September 5, 2025 13:39
@colinrotherham colinrotherham temporarily deployed to nhsuk-frontend-pr-1565 September 5, 2025 13:39 Inactive
@colinrotherham colinrotherham force-pushed the component-character-count-localise branch from 9bc97af to c96b3fd Compare September 5, 2025 13:52
@colinrotherham colinrotherham temporarily deployed to nhsuk-frontend-pr-1565 September 5, 2025 13:52 Inactive
@colinrotherham colinrotherham force-pushed the component-character-count-localise branch from c96b3fd to 8f6afe3 Compare September 5, 2025 14:30
@colinrotherham colinrotherham force-pushed the component-character-count-localise branch from 8f6afe3 to 07adb72 Compare September 5, 2025 14:32
@colinrotherham colinrotherham force-pushed the component-character-count-localise branch from 07adb72 to 0092409 Compare September 5, 2025 14:57
@colinrotherham colinrotherham force-pushed the component-character-count-localise branch from 0092409 to 935f481 Compare September 5, 2025 15:00
@colinrotherham colinrotherham temporarily deployed to nhsuk-frontend-pr-1565 September 5, 2025 15:01 Inactive
@colinrotherham colinrotherham force-pushed the component-form-inputs branch 2 times, most recently from 34919b2 to 3c583e3 Compare September 5, 2025 17:54
@colinrotherham colinrotherham force-pushed the component-character-count-localise branch from 935f481 to 3aac68d Compare September 5, 2025 17:55
@colinrotherham colinrotherham temporarily deployed to nhsuk-frontend-pr-1565 September 5, 2025 17:55 Inactive
@colinrotherham colinrotherham force-pushed the component-character-count-localise branch from 3aac68d to b48dc8a Compare September 5, 2025 19:51
@colinrotherham colinrotherham temporarily deployed to nhsuk-frontend-pr-1565 September 5, 2025 19:51 Inactive
@colinrotherham colinrotherham temporarily deployed to nhsuk-frontend-pr-1565 September 9, 2025 16:54 Inactive
@colinrotherham colinrotherham temporarily deployed to nhsuk-frontend-pr-1565 September 19, 2025 12:06 Inactive
@anandamaryon1 anandamaryon1 temporarily deployed to nhsuk-frontend-pr-1565 September 24, 2025 08:19 Inactive
Comment thread packages/nhsuk-frontend/src/nhsuk/components/character-count/macro-options.mjs Outdated
@anandamaryon1 anandamaryon1 temporarily deployed to nhsuk-frontend-pr-1565 September 24, 2025 08:51 Inactive
@anandamaryon1 anandamaryon1 temporarily deployed to nhsuk-frontend-pr-1565 September 24, 2025 09:15 Inactive
@sarawilcox sarawilcox moved this from Needs review to Ready to release in Service Manual Sprint Board Oct 6, 2025
@colinrotherham colinrotherham force-pushed the component-character-count-localise branch from b4b6675 to ba85dc1 Compare October 7, 2025 11:42
@colinrotherham colinrotherham temporarily deployed to nhsuk-frontend-pr-1565 October 7, 2025 11:43 Inactive
Base automatically changed from component-form-inputs to main October 7, 2025 13:39
The intersection of browsers that support ES6 modules (and therefore run our JavaScript) but do not support `Intl.PluralRules` is relatively small:

- Safari 10.3 - 12.5 on iOS
- Safari 10.1 - 12.1 on macOS
- Edge 16-18
- Chrome 61-62
- Opera 48-49

These browsers represent a tiny percentage of users and do not justify the overhead of including the extra JavaScript to implement the fallback logic, so let’s remove it.

These browsers will instead fall back to the ‘other’ translation. For example, when using the Character Count in English it will display ‘You have 1 characters remaining’ rather than the singular translation ‘You have 1 character remaining’.
@colinrotherham colinrotherham force-pushed the component-character-count-localise branch from ba85dc1 to 16a9e1f Compare October 7, 2025 13:44
@colinrotherham colinrotherham temporarily deployed to nhsuk-frontend-pr-1565 October 7, 2025 13:44 Inactive
@colinrotherham
Copy link
Copy Markdown
Contributor Author

colinrotherham commented Oct 7, 2025

@anandamaryon1 Good to go with the changelog entry?

As discussed, I've also removed the line-height: 1.25; override from textarea components

We added this to align with GOV.UK Frontend in #1567 but we prefer it wider

@colinrotherham colinrotherham temporarily deployed to nhsuk-frontend-pr-1565 October 8, 2025 07:42 Inactive
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Oct 8, 2025

@colinrotherham colinrotherham merged commit ce1d50e into main Oct 8, 2025
13 checks passed
@colinrotherham colinrotherham deleted the component-character-count-localise branch October 8, 2025 08:18
@colinrotherham colinrotherham self-assigned this Oct 15, 2025
@Smartin684 Smartin684 moved this from Ready to release to Done in Service Manual Sprint Board Oct 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done - 2025

Development

Successfully merging this pull request may close these issues.

5 participants