Feature Request: Built-in helpers for getLocaleFromRequest #3516
ratsclub
started this conversation in
Ideas + Feature Requests
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Problem
Almost every Hydrogen project that supports some internationalization needs to implement a custom
getLocaleFromRequestutility function. These custom functions often have multiple fallback rules around domain TLDs, subdomains, cookies, headers and path matching.Proposal
It would be great if Hydrogen shipped built-in utility functions (or a configurable helper) to handle locale detection from a request. This could support multiple detection strategies out of the box (URL path, subdomain, domain, Accept-Language header, cookies) and integrate cleanly with the i18n option in createStorefrontClient.
A starting point?
I've built a small library request-locale that tackles this problem using the standard Web Request API and a few composable functions. It could serve as a reference or starting point for a built-in solution.
Happy to contribute or discuss the API design further. Would love to hear the team's thoughts on this!
Beta Was this translation helpful? Give feedback.
All reactions