How does slot content localization work with Shopify Markets on Hydrogen?
We run a Hydrogen store with Shopify Markets serving three locales: tr, en, and de. The locale is in the URL prefix and our loaders already know it.
My questions:
-
How does Croct know which locale the visitor is in? Does it detect it, or do we pass it?
-
Does each locale need its own slot? Three locales times every slot would be heavy to maintain.
-
What happens for a locale we have not listed, for example a visitor from a market we do not localize yet
1 answer
In order:
-
You pass it. Since your loaders already know the locale from the URL, set the preferredLocale option on the content fetch and Croct returns the localized content for that slot. If the whole app runs in one locale per request, you can also set defaultPreferredLocale once in the plug configuration instead of passing it on every fetch.
-
No. One slot serves all locales. Localized content lives inside the same slot, so you keep one home-hero, not three. Per-locale default content is part of the localization add-on rather than something you model with separate slots.
-
If the requested locale has no localized content, the slot's default content is served. So an unlisted market gets your default language rather than an error or an empty slot.
The practical upshot for your setup: the loader passes the market's locale through, and adding a fourth market later is a content task, not new slots or new code.