Forum Archive - Change language using a URL parameter: site.com?lang=DE

Change language using a URL parameter: site.com?lang=DE
Jan 4, 2018 4:16 pm by jivan
Hello, I want to change the language of my website from EN to DE without using the dropdown menu but with a command. The ideal solution would be with a parameter in the URL, for example: http://www.mysite.com?lang=de" rel="nofollow" target="_blank I already contacted the support and they suggested me to add the following javascript code in the header to change the language via javascript: <script type="text/javascript"> if (localStorage.getItem("ChangeLanguageFirstTime") === null) { doGTranslate('en|de'); localStorage.setItem("ChangeLanguageFirstTime", true); } </script> I tried it but it does not work. Is there any other solution? Thanks in advance
Re: Change language using a URL parameter: site.com?lang=DE
Jan 9, 2018 3:01 pm by jivan
I've retried and seems that the javascript function: doGTranslate('en|de') works correctly if there is a GTranslate widget on the website.
Re: Change language using a URL parameter: site.com?lang=DE
Jan 10, 2018 9:16 pm by Yana
Hi, Yes, the function will work if gtranslate code is in your website. If you do not want to show the language switcher you can hide it using css or just copy gtranslate javascript code without language switcher html and add to the head tag of your website. Regards, Yana
Re: Change language using a URL parameter: site.com?lang=DE
Jan 11, 2018 8:09 am by jivan
Hi Yana, ok, thanks for ther suggestion. Regards
Re: Change language using a URL parameter: site.com?lang=DE
Jan 11, 2018 3:56 pm by Yana
You are welcome !

SIMILAR TOPICS

Large numbers of crawl errors with double language codeJan 24, 2019 1:43 amReplies: 1Post by: natastna2
Translate website to any specific language, on page loadJan 19, 2019 6:49 amReplies: 1Post by: Leaon7756
how to translate site right to left for arabic in WordPressDec 26, 2018 9:02 amReplies: 1Post by: Hammond753
Graphic translation for every language is missingDec 19, 2018 7:54 amReplies: 1Post by: Daryl Dixon
How to remove mobile Language Select Button transparencyDec 5, 2018 10:06 pmReplies: 10Post by: JeffTR

Try GTranslate with a free 15 day trial