Nikolas361 Posted June 20, 2023 Posted June 20, 2023 Heyhey, I set up a multilingual site with the Brad Good method. Worked all well but when I tried to implement his code for URL mapping of the language switcher (i.e., switching language and arriving at the corresponding site in the other language), I got stuck. It just doesn't want to work and I can't figure out why. Can anybody help? https://www.bieleit-medicus.com/ This is the code for the URL mapping: Quote <script> $(function() { switch (window.location.pathname) { case '/en/about': $(".language a.lang-en").attr("href", "/en/about"); $(".language a.lang-de").attr("href", "/de/uebersicht"); break; case '/de/uebersicht': $(".language a.lang-en").attr("href", "/en/about"); $(".language a.lang-de").attr("href", "/de/uebersicht"); break; case '/en/services': $(".language a.lang-en").attr("href", "/en/services"); $(".language a.lang-de").attr("href", "/de/leistungen"); break; case '/de/leistungen': $(".language a.lang-en").attr("href", "/en/services"); $(".language a.lang-de").attr("href", "/de/leistungen"); break; case '/en/bio-contact': $(".language a.lang-en").attr("href", "/en/bio-contact"); $(".language a.lang-de").attr("href", "/de/ueber-mich-kontakt"); break; case '/de/ueber-mich-kontakt': $(".language a.lang-en").attr("href", "/en/bio-contact"); $(".language a.lang-de").attr("href", "/de/ueber-mich-kontakt"); break; } }); </script>
Solution creedon Posted June 21, 2023 Solution Posted June 21, 2023 The issue is the code is using jQuery but you've put the code before jQuery has had a change to run, so it breaks. Move the code after jQuery and the BG code. Let us know how it goes. Nikolas361 1 Find my contributions useful? Please like, upvote, mark my answer as the best ( solution ), and see my profile. Thanks for your support! I am a Squarespace ( and other technological things ) consultant open for new projects.
Nikolas361 Posted June 21, 2023 Author Posted June 21, 2023 ahh so easy in the end. Didn't think about that, thanks heaps!! creedon 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment