Have your say in Community Polls: What was/is your greatest motivation to start your own business?

How can I save a visitor's language preference without redirect?

How can I save a visitor's language preference without redirect?

hazzardt
Tourist
22 0 3

Seriously can't find this anywhere. If visitor chooses language "Spanish" for example, how do I save that for all future visits? I have a javascript around right now, but it involves a redirect on a re-visit, which I'm not a fan of. I'd prefer displaying spanish language immediately, without a redirect to "/es" folder. How would I achieve this? I've seen some website make it work, but can't figure it out myself and can't find any documentation either.

Replies 3 (3)

richbrown_staff
Shopify Staff
652 96 167

Language preference is saved to that browser's cookie, so there's nothing you need to do here. There isn't a redirect to /es folder, rather /es is where Spanish is (if that's how your store is setup), if that makes sense. Different languages have different URL paths

To learn more visit the Shopify Help Center or the Community Blog.

hazzardt
Tourist
22 0 3

Thanks for the answer! I’m aware, but I noticed some website achieved language preference cookie saving, which loads automatically on a re-visit, without redirecting to the language folder. Website I’m talking about is pdpaola.com, if you want to check. Just change the language and then vidit the root again, translation stays, but no redirect occurs.

richbrown_staff
Shopify Staff
652 96 167

Thanks for sharing that @hazzardt . We took a look internally - they are saving a customer_locale cookie which is custom to them; definitely not something Shopify does as standard. Our position is very much that a language should have its own URL structure. Sorry to not be able to be more help.

To learn more visit the Shopify Help Center or the Community Blog.