Add Hydrogen context provider for i18n overrides #2739
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
WHY are these changes introduced?
Fixes #2507
useMoney
andMoney
inside Hydrogen don't respect i18n localization params passed to the storefront context as those components take the localization data from a wrappingShopifyProvider
.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?
HydrogenContext
that contains the i18n data (country and language codes).useShop
hook (used byuseMoney
) to override the context data coming fromShopifyProvider
with the values coming fromHydrogenContext
(if present).Layout
function so that it wraps everything withHydrogenContext.Provider
.Checklist