Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>@mogelbrod code isn't always working so I hacked it a bit.</p> <p>If user is logged in Google Account, Google will detect it's language and automatically translate language text so you won't be able to fire event on desired element because data-lang attribute won't be correct!</p> <p>Users that aren't logged in Google Account and American / English users will have this. <img src="https://i.stack.imgur.com/bO7Yx.png" alt="en"></p> <p>And for example; Croatian users will have this.</p> <p><img src="https://i.stack.imgur.com/ruhq0.png" alt="hr"></p> <p>In this case it's better to map language order. For example from above, that would be</p> <blockquote> <p>0 - English</p> <p>1 - French</p> <p>2 - German</p> <p>3 - Italian</p> </blockquote> <p>HTML:</p> <p>Note the data-placement property (you can change element order, but preserve placement as above).</p> <pre><code>&lt;div class="translation-icons" style="visibility:hidden"&gt; &lt;a href="#" class="eng" data-placement="0"&gt;eng icon&lt;/a&gt; &lt;a href="#" class="fra" data-placement="1"&gt;fra icon&lt;/a&gt; &lt;a href="#" class="ger" data-placement="2"&gt;ger icon&lt;/a&gt; &lt;a href="#" class="ita" data-placement="3"&gt;ita icon&lt;/a&gt; &lt;/div&gt; </code></pre> <p>JS: I had to change find selector. Note that when user choses language, there's no more "Choose Language" element in #google_translate_element div so I had to handle that, too.</p> <p>Also it's good not to show icons until all scripts (google translate) are loaded.</p> <pre><code>$(window).load(function () { $('.translation-icons').css('visibility', 'visible'); $('.translation-icons a').click(function(e) { e.preventDefault(); var placement = $(this).data('placement'); var lang_num = $('.translation-icons a').length; var $frame = $('.goog-te-menu-frame:first'); if (!$frame.size()) { alert("Error: Could not find Google translate frame."); return false; } var langs = $('.goog-te-menu-frame:first').contents().find('a span.text'); if(langs.length != lang_num) placement = placement+1; langs.eq(placement).click(); return false; }); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload