Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google translate using a link click

I recently saw a website that used Google Translate in their page, but instead of using the widget, they listed the available languages via links. Click a link and it translates the page.

Has anyone ever done this? I tried to parse through the page to figure out how it was done but I don't see much different than when I use the widget. Here's some of my code:

<h3>Translate</h3>
<ul class="google-translate-six">
    <li><a href="?/#googtrans(en|es)" title="View this site in Spanish.">Español</a></li>
    <li><a href="?/#googtrans(en|zh-CN)" title="View this site in Chinese.">中文</a></li>
    <li><a href="?/#googtrans(en|it)" title="View this site in Italian.">Italiano</a></li>
    <li><a href="?/#googtrans(en|pl)" title="View this site in Polish.">Polskie</a></li>
    <li><a href="?/#googtrans(en|ht)" title="View this site in Haitian Creole.">Kreyòl Ayisyen</a></li>
    <li><a href="?/#googtrans(en|pt)" title="View this site in Portuguese.">Português</a></li>
    <li><a href="?/#googtrans(en|en)" title="View this site in English.">English</a></li>
</ul>

<script type="text/javascript">
    function googleTranslateElementInit() {
    new google.translate.TranslateElement({
    pageLanguage: 'en',
    autoDisplay: false,
    gaTrack: true,
    gaId: 'wewe',
    layout: google.translate.TranslateElement.InlineLayout.SIMPLE
    }, 'google_translate_element');
  }
</script>
<script src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>

Thanks! The site I'm referring to is: https://www.baltimorecountymd.gov/index.html. The Translate section is at the bottom right portion of the page.

Thanks everyone!

like image 423
tahdhaze09 Avatar asked Oct 12 '17 14:10

tahdhaze09


People also ask

How do you translate a web link?

Just go on Google Translate and paste the URL to translate in the left box. Select your target (and source) language and click on the resulting link in the right box. You will be redirected to the translated website in the desired language. The URL can be shared with others to share the translated website.


1 Answers

I believe this page is what you're looking for.

like image 114
Jiroscopes Avatar answered Oct 13 '22 00:10

Jiroscopes