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

Popular automatic website translation tool

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

Postby jivan » Thu Jan 04, 2018 8:16 pm

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
jivan
 
Posts: 3
Joined: Thu Jan 04, 2018 8:10 pm

Re: Change language using a URL parameter: site.com?lang=DE

Postby jivan » Tue Jan 09, 2018 7:01 pm

I've retried and seems that the javascript function:

doGTranslate('en|de')

works correctly if there is a GTranslate widget on the website.
jivan
 
Posts: 3
Joined: Thu Jan 04, 2018 8:10 pm

Re: Change language using a URL parameter: site.com?lang=DE

Postby Yana » Thu Jan 11, 2018 1:16 am

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
Regards,

Yana Ghahramanyan - GTranslate Team

Please leave your feedback on your CMS plugin directory. It is very important for us!
Google Translate Joomla
Google Translate WordPress
Google Translate Drupal
Yana
 
Posts: 4407
Joined: Thu Jan 12, 2012 6:21 pm

Re: Change language using a URL parameter: site.com?lang=DE

Postby jivan » Thu Jan 11, 2018 12:09 pm

Hi Yana,

ok, thanks for ther suggestion.

Regards
jivan
 
Posts: 3
Joined: Thu Jan 04, 2018 8:10 pm

Re: Change language using a URL parameter: site.com?lang=DE

Postby Yana » Thu Jan 11, 2018 7:56 pm

You are welcome !
Regards,

Yana Ghahramanyan - GTranslate Team

Please leave your feedback on your CMS plugin directory. It is very important for us!
Google Translate Joomla
Google Translate WordPress
Google Translate Drupal
Yana
 
Posts: 4407
Joined: Thu Jan 12, 2012 6:21 pm


  • Related Topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 3 guests

2GLux