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.
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.
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.