Why window.location.assign(url) works then shopify redirects it back

Hi All,

I have test in my javascript google console, during testing and also in a liquid file, but commented out,

I have two spans, with two language flags, that on click calls a js function.

The code changes the language successfully to spanish appending /es/ to the url

like domainname.com/es using javascript;
window.location.assign( /es/ ) url,

but then after shopify sets the url back to english again by itself, to domainname.com/

So what other setting do I need to set to keep the language change setting?

a cookie, or shopify api call, what is causing the page to redirect back to its default english setting?

Because when I just type domainname.com/es it works, when I do it in javascript in the browser console with:

window.location.assign(‘domainname.com/es’) it works, then immediately shopify redirects the page back to the english language domainname.com again by itself, why ?