Frequently Asked Questions
Here are a couple common questions about the TranslateThis Button:
- Why does the script automatically translate pages?
- How do I change the button image?
- Can I change the text to match my language?
- How do I enable Google Analytics tracking?
- How do I change the languages in the dropdown?
- How do I prevent translation on certain sections of my web page?
- How do disable automatic translation?
- Once the translation runs, certain functionality of my site breaks. Help!
- How is this different from Google Translate?
Don't see your question? Ask it!
Why does the script automatically translate pages?
Once a user translates a page on your site, any of the other pages they visit on your site will be automatically translated. This allows the script to translate your entire site, and won't effect other visitors.
At any time the user can stop the automatic translation either by clicking the "cancel" link during the translation or the "undo" link after the translation completes.
Additionally if the page is translated back into the original language, the automatic translation will stop (provided that the fromLang option is set - See here).
If you would prefer not to use the automatic translation functionality at all, you can disable it. See here for more details
How do I change the button image?
There are a couple ways to change the button image.
1. Easiest is to style the button with CSS using !important:
#translate-this .translate-this-button {
background-image: url(my-image-path.jpg) !important;
width: 250px !important;
height: 50px !important;
}
2. Or use an image inside the link and disable the button styling:
<!-- Begin TranslateThis Button -->
<div id="translate-this"><a href="http://translateth.is/"
class="translate-this-button"><img src="my-image-path.jpg" alt=""
style="border: 0" /></a></div>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript"
src="http://x.translateth.is/translate-this.js"></script>
<script type="text/javascript">
TranslateThis({
noBtn : true
});
</script>
<!-- End TranslateThis Button -->
3. And finally the best way is to set it all with Javascript:
<script type="text/javascript">
TranslateThis({
btnImg : 'my-image-path.jpg',
btnHeight : 250,
btnWidth : 50
});
</script>
Note – If you're using the Wordpress Plugin, this option can be set from the settings page
Can I change the text to match my language?
Yes, you set a number of text options for the TranslateThis Button:
<script type="text/javascript">
TranslateThis({
panelText : 'Translate Into:',
moreText : '36 More Languages »',
busyText : 'Translating page...',
cancelText : 'cancel',
doneText : 'This page translated by the',
undoText : 'Undo »'
});
</script>
Note – If you're using the Wordpress Plugin, this option can be set from the settings page
How do I enable Google Analytics tracking?
To enable Google Analytics tracking, pass the option GA set to true:
<!-- Begin TranslateThis Button -->
<div id="translate-this"><a href="http://translateth.is/"
class="translate-this-button">Translate</a></div>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript"
src="http://x.translateth.is/translate-this.js"></script>
<script type="text/javascript">
TranslateThis({
GA : true
});
</script>
<!-- End TranslateThis Button -->
Then the TranslateThis Button will handle the rest, tracking each language translation as a pageview such as 'TranslateThis-es' for Spanish. See list of language slugs.
Note – If you're using the Wordpress Plugin, this option can be set from the settings page
How do I change the languages in the dropdown?
You can set the languages in the dropdown passing the Google language codes as an array to the ddLangs option. For instance, let's take out Czech and add English at the top of the list:
<script type="text/javascript">
TranslateThis({
ddLangs : [
'en',
'fr',
'es',
'ar',
'zh-CN',
'ko',
'it',
'iw',
'de',
'pt-PT',
'ru',
'ja',
'vi',
'el',
'hi',
'tr'
]
});
</script>
Note – If you're using the Wordpress Plugin, this option can be set from the settings page
How do I prevent translation on certain sections of my web page?
If you want to disable translation on a certain section of your page, simple add class="notranslate" to any HTML element to prevent it from being translated.
You can also restrict the scope to translate a specific portion of your web page. Then use the class="notranslate" method to prevent translation on elements within this scope element (which defaults to the entire page).
How do I disable automatic translation?
When a user chooses a language, a cookie is set so that the TranslateThis Button can translate other pages on your site automatically. If you want to disable this, set cookie to false :
<script type="text/javascript">
TranslateThis({
cookie : false
});
</script>
Note – If you're using the Wordpress Plugin, this option can be set from the settings page
Once the translation runs, certain functionality on my site breaks
Unfortunately when the translation event runs, it will remove any Javascript events you have attached (click, mouseover, submit, etc.). If it's a jQuery site, try using live() events in place of your existing events.
Alternately, you can use the onComplete callback function provided by TranslateThis to reattach any events you need after the translation completes.
How is the TranslateThis Button different from Google Translate?
The TranslateThis Button leverages the Google Language API so the translation it provides is the same as Google Translate. However it provides a number of advantages over Google Translate's widget.
First Google Translate's widget is an ugly dropdown of languages, while the TranslateThis Button provides a nice user interface to access the languages.
But more importantly, the TranslateThis Button doesn't redirect users to translate.google.com, meaning that it allows you to retain the users on your site, along with any linkbacks, tracking data, etc.
Finally the scripts processes the translation with a number of parallel Javascript calls, meaning that for most websites the translation is faster than Google Translate.