Skip to content

refactor(i18n): replace handlebars-intl adapter#1685

Open
paulfalgout wants to merge 1 commit intodevelopfrom
i18n
Open

refactor(i18n): replace handlebars-intl adapter#1685
paulfalgout wants to merge 1 commit intodevelopfrom
i18n

Conversation

@paulfalgout
Copy link
Copy Markdown
Contributor

@paulfalgout paulfalgout commented May 5, 2026

Closes FE-120

What

  • Replace handlebars-intl with @formatjs/intl
  • Add a local Handlebars i18n adapter for formatMessage, formatDate, intlGet, and formatHTMLMessage
  • Add component coverage for ICU plural formatting and HTML escaping

Why

handlebars-intl is a thin adapter over FormatJS. Owning the small adapter locally removes an old dependency layer while preserving existing template behavior.

Testing

  • npx cypress run --component --spec src/js/base/helpers.cy.js
  • npm run lint

Summary by cubic

Replaced handlebars-intl with a local Handlebars i18n adapter built on @formatjs/intl, fixed ICU select handling by adding other branches, and preserved HTML message tags with safe escaping. Addresses FE-120 with no template changes and clearer errors for invalid inputs.

  • Refactors

    • Added src/js/i18n/intl.js with formatMessage, formatDate, intlGet, formatHTMLMessage, and an intl block helper; registered with handlebars and handlebars/runtime. Updated i18n README.
    • Removed handlebars-intl and added @formatjs/intl.
  • Bug Fixes

    • Added other branches to ICU selects in en-US.yml.
    • Preserved HTML tags while escaping values in formatHTMLMessage. Added tests for selects, number formatting, HTML, and invalid input errors.

Written for commit 9648072. Summary will update on new commits.

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 6 files

@cypress
Copy link
Copy Markdown

cypress Bot commented May 5, 2026

RoundingWell Care Ops Frontend    Run #8910

Run Properties:  status check passed Passed #8910  •  git commit 9648072821: refactor(i18n): replace handlebars-intl adapter
Project RoundingWell Care Ops Frontend
Branch Review i18n
Run status status check passed Passed #8910
Run duration 02m 02s
Commit git commit 9648072821: refactor(i18n): replace handlebars-intl adapter
Committer Paul Falgout
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 236
View all changes introduced in this branch ↗︎

This comment was marked as resolved.

Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 4 additional findings.

Open in Devin Review

@coveralls
Copy link
Copy Markdown

coveralls commented May 5, 2026

Coverage Report for CI Build 6

Coverage remained the same at 100.0%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: 53 of 53 lines across 2 files are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 6105
Covered Lines: 6105
Line Coverage: 100.0%
Relevant Branches: 1882
Covered Branches: 1882
Branch Coverage: 100.0%
Branches in Coverage %: Yes
Coverage Strength: 295.79 hits per line

💛 - Coveralls

@paulfalgout paulfalgout force-pushed the i18n branch 2 times, most recently from 74f587c to 2420a08 Compare May 5, 2026 06:59
Comment thread src/js/i18n/en-US.yml
dueButton: Due
updateButton: Updated
dateTypes: "{type, select, created_at {Added} due_date {Due} updated_at {Updated}}"
dateTypes: "{type, select, created_at {Added} due_date {Due} updated_at {Updated} other {}}"
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The newer version of FormatJS requires every ICU select message to include an other branch. Without it, those messages fail validation and render unformatted ICU text. The empty other {} branches preserve the prior fallback behavior while making the messages valid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants