APIs & Integrations

patrickhummel
Contributor

Language Switcher Code - where to find?

Hello Developers community,

I created an own language switcher (and no, it was not possible to bring this design to the existing switcher) and I would like to know which code is implemented in the original switcher template so I can get the rewrite function of the URL to the other language.

Thank you very much for any help!
Pat

0 Upvotes
2 Replies 2
patrickhummel
Contributor

Language Switcher Code - where to find?

Hi Derek,

this is not the behavior I am searching. I am searching for the link or the PHP code generated to switch to the other language. I have an a-tag and I will put just a link in it to swith to the only different language fr-ch. From de to fr-ch.

I set window.fr-ch as link but nothing happened.

Derek_Gervais
HubSpot Alumni
HubSpot Alumni

Language Switcher Code - where to find?

Hi @patrickhummel,

You can replicate the behavior of the language switcher module by setting window.location to the page URL with the language slug of the selected language. Each language version of a page is just the domain, a language slug (or for your primary language, no slug) and the page path. For example, if your primary language is English and your english page is www.example.com/example_page, you can switch to the French version of your page by setting window.location to www.example.com/fr/example_page.