Language changes back to default after setting correct localization

Topic summary

Issue: Language switches back to English after initial German localization, especially when navigating or during checkout.

Key findings:

  • Shopify does not auto-set language by IP. The problem stemmed from hardcoded links and a custom redirect.
  • Store logo/home was redirecting to a product URL without the locale subfolder (e.g., /products/… instead of /de/products/…), forcing English.

Actions taken:

  • Removed custom redirect code from theme.liquid that sent the homepage to a product page. Result: homepage now respects locale.
  • Replaced hardcoded “/cart” in header.liquid with the localized Liquid route {{ routes.cart_url }}. Result: cart link now stays in the chosen language.

Remaining problem:

  • The “Add to cart” button triggers a redirect to “/cart” via theme.min.js. Attempting to use {{ routes.cart_url }} inside the .js asset didn’t work (Liquid isn’t processed in static JS files).
  • Cart drawer/modal works as a workaround, but a locale-aware redirect from the button is still unresolved.

Status:

  • Most localization issues fixed (navigation and cart link). Open question: how to implement a locale-aware cart redirect from JavaScript without Liquid. Another participant reported the same issue and requested the solution.
Summarized with AI on December 24. AI used: gpt-5.

Hi!

When visiting my site for the first time, the language selector perfectly does its job and chooses Germany. But, as soon as I open a different site, e.g. imprint / contact and come back to the main page → It resets language to default (English). Could cookies be the issue here? Even when I open the the main domain again like a new user, it does not localize anymore and you have to change it manually to German.

This is also happening when I put something into the cart. As soon as I am getting forwarded. Language switches back to English and does not stay in German.

Thanks for your support!

Hi @Pixel-User

What is your current location? Are you in Germany or the UK?

Hi, I am currently in Germany. And this happens in my browser as well as on my smartphone.

Hi @Pixel-User , there’s no link between IP location and language in Shopify so it’s not that. Most often this happens because a link in your menu / navigation is hard coded, e.g. it’s linking to www.example.com rather than in Online Store > Navigation selecting the homepage, if that makes sense. Rich

Hi @richbrown_staff
I think I understand a bit, but I don’t know how to change this :thinking:
I am currently not at home but will test this week.

Could this also be related to the theme? Because the main problem or issue is, I load the page and it switches automatically to German but as soon as I click on the card, the checkout process is completely in English and I have to switch manually back to German.

Hi @Pixel-User , I’ve looked at your store and I’m not sure how you’ve done this but there is a redirect somewhere in your store - if I click the logo it redirects to (yourwebsite.com)/products/sliibox?variant=47950846755151 - any idea how that would have got in there?

Hi @richbrown_staff
Yes, my goal was to have on the very mainpage only one product, the main product. That’s why I redirected it directly to the product. Do you think, that could the reason?

I got the tip from somewhere else and edited the theme code anywhere (I think it was in the header area to redirect directly to the product) so that it redirects not to the starting page, instead I wanted a solo product page.

Hope this is understandable.

P.S.: Sorry got the late reply.

Hey @Pixel-User , this will be the reason, yes. I can’t see where you’re doing it in the code, but if it’s redirecting to (yourwebsite.com)/products/sliibox?variant=47950846755151 then there is no locale subfolder, i.e. it is not redirecting to (yourwebsite.com)/de/products/sliibox?variant=47950846755151 so it’ll be in English, not German.

There is not an easy way to set a product page as a homepage. Obviously it’s entirely up to you how you build your store, but I would say it’s uncommon. Perhaps featuring your product heavily on the homepage, making it easy to click into the product page, would be the way to go - as opposed to a redirect.

**Hi @richbrown_staff **
First of all, sorry for my late reply. The holidays and so on…

I think I found the changed code:

I edited the code in the file “theme.liquid” and added the following code before the tag:

{%- if template contains 'index' -%}

{%- endif -%}

I think this was the issue, now it redirects (after removing this) again back to the main page. Now I have to change the look of it unfortunately as well :disappointed_face:

Thanks so much for your awesome support. So much appreciated and happy new year.

Update: Now I got a different problem → The page is in German, like sliibox.com/de but whenever I add something to the cart it goes to sliibox.com/cart → which is the english version, why it is not switching / using the German translation, coming from the German main page. Any ideas for that? Thanks again

Update 2: Got it! Changed in the header.liquid from “/Cart” to “{{ routes.cart_url }}”, found the solution in a different thread in your awesome support community. Thanks again.

My only problem left now is, that when the add to cart button is clicked (in German) it redirect to the page “/cart”

I changed it in “theme.min.js” to “{{ routes.cart_url }}” but this does not seem working within the .js-file, right? Any other ideaa how I could make it redirect the “add to cart” button to the “{{ routes.cart_url }}” page instead of “/cart”?

In the cart drawer and modal it is working by the way and this might be the workaround for this. But I prefer the redirect to be honest :/.

My only problem left now is, that when the add to cart button is clicked (in German) it redirect to the page “/cart”

Hi, I’m having the same problem, how did you solve this problem? I would appreciate if you could help me.