开发者

Is it possible to trigger a Javascript action through a HTaccess redirect?

开发者 https://www.devze.com 2023-02-28 19:41 出处:网络
I have a website with a lot of language subfolders /de/ /fr/ /es/ etc and I am using a combination of redirected/cached translation and uncached onthefly transla开发者_JS百科tion. I need the Cart area

I have a website with a lot of language subfolders /de/ /fr/ /es/ etc and I am using a combination of redirected/cached translation and uncached onthefly transla开发者_JS百科tion. I need the Cart areas of my site to be cached onthefly rather than redirected which it is at the moment. However, I'd like to be able to make the foreign language experience seamless so the customer doesnt have to click on the flag again once the translation type has changed. They'll be coming into the cart through /de/cart. As an example if I was a German customer I would be happily in the /de/ German subfolder with everything in my language but when I go to the cart, I get knocked back to English and have to click the flag again as the redirect has changed. My problem really is that I don't know how to trigger the translation without having a url to direct it to. I thought something like this might work:

redirect 301 /de/cart http://www.my-site.com/cart?lang=de

But this obviously does nothing because I don't know how to say to Google Translate I want to trigger this language. Thanks for taking the time to read this and any help would be greatly appreciated. It might in fact be impossible to achieve this in the way I am trying so a simple not possible would also help :-)


In the javascript you have to parse window.location to find the lang=de and then take action based on the result.

However, it seems strange to me that you are using google translate on your page -- if you want localized versions write the code to do so -- google translate is an external tool and not a very good one compared to a true translation.

0

精彩评论

暂无评论...
验证码 换一张
取 消