Skip to content

feat: Add public useI18n hook - #4854

Open
radsacha wants to merge 1 commit into
cloudscape-design:mainfrom
radsacha:feat/public-use-i18n-hook
Open

feat: Add public useI18n hook#4854
radsacha wants to merge 1 commit into
cloudscape-design:mainfrom
radsacha:feat/public-use-i18n-hook

Conversation

@radsacha

@radsacha radsacha commented Aug 2, 2026

Copy link
Copy Markdown

Summary

Add a public namespace-aware useI18n(namespace, component) hook from @cloudscape-design/components/i18n.

This lets component libraries built on top of Cloudscape resolve their own translated strings through the existing I18nProvider message context, without exposing InternalI18nContext or changing Cloudscape's internal useInternalI18n hook.

Changes

  • Add useI18n(namespace, component) as a thin public wrapper around the existing formatter.
  • Export useI18n and I18nFormatFunction from @cloudscape-design/components/i18n.
  • Add unit coverage for custom namespaces, provided-value precedence, no-provider fallback, locale widening, custom handlers, multiple namespaces, nested providers, and shared Cloudscape/third-party provider usage.

Non-goals

  • No I18nProvider behavior changes.
  • No message format or bundle shape changes.
  • No changes to useInternalI18n or Cloudscape component typing.

Testing

  • npm run quick-build
  • node_modules/.bin/eslint src/i18n/context.ts src/i18n/index.ts src/i18n/__tests__/use-i18n.test.tsx
  • TZ=UTC node_modules/.bin/jest -c jest.unit.config.js src/i18n/__tests__/use-i18n.test.tsx src/i18n/__tests__/i18n.test.tsx
  • TZ=UTC node_modules/.bin/jest -c jest.unit.config.js src/__tests__/functional-tests/public-exports.test.ts
  • git diff --check

@radsacha
radsacha requested a review from a team as a code owner August 2, 2026 01:31
@radsacha
radsacha requested review from SpyZzey and removed request for a team August 2, 2026 01:31
@radsacha radsacha changed the title feat: Add public i18n hook feat: Add public useI18n hook Aug 2, 2026
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.

1 participant