Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add Hydrogen context provider for i18n overrides #2739

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ruggishop
Copy link
Contributor

@ruggishop ruggishop commented Jan 31, 2025

WHY are these changes introduced?

Fixes #2507

useMoney and Money inside Hydrogen don't respect i18n localization params passed to the storefront context as those components take the localization data from a wrapping ShopifyProvider.

There are multiple possible ways of tackling this, with the spectrum going from introducing breaking changes, to adding renamed counterparts that receive explicit i18n data, to introducing a Hydrogen specific context that overrides the localization data. This PR implements the approach of the H2 context.

WHAT is this pull request doing?

  • Introduce a new HydrogenContext that contains the i18n data (country and language codes).
  • Update the useShop hook (used by useMoney) to override the context data coming from ShopifyProvider with the values coming from HydrogenContext (if present).
  • Update the skeleton template's Layout function so that it wraps everything with HydrogenContext.Provider.

Checklist

  • I've read the Contributing Guidelines
  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've added a changeset if this PR contains user-facing or noteworthy changes
  • I've added tests to cover my changes
  • I've added or updated the documentation

Copy link
Contributor

shopify bot commented Jan 31, 2025

Oxygen deployed a preview of your feat/fr-hydrogen-context-i18n branch. Details:

Storefront Status Preview link Deployment details Last update (UTC)
Skeleton (skeleton.hydrogen.shop) ✅ Successful (Logs) Preview deployment Inspect deployment January 31, 2025 2:37 PM
metaobjects ✅ Successful (Logs) Preview deployment Inspect deployment January 31, 2025 2:37 PM
third-party-queries-caching ✅ Successful (Logs) Preview deployment Inspect deployment January 31, 2025 2:36 PM
custom-cart-method ✅ Successful (Logs) Preview deployment Inspect deployment January 31, 2025 2:37 PM
classic-remix ✅ Successful (Logs) Preview deployment Inspect deployment January 31, 2025 2:36 PM

Learn more about Hydrogen's GitHub integration.

@ruggishop ruggishop changed the title Add Hydrogen context for i18n overrides Add Hydrogen context provider for i18n overrides Jan 31, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Money component and useMoney hook don’t respect app language format
1 participant