I use this script in my site for translation
<div id="google_translate_element" align="center"></div>
<script type="text/javascript">
function googleTranslateElementInit() {
new google.translate.TranslateElement({
pageLanguage: 'auto',
autoDisplay: false,
layout: google.translate.TranslateElement.InlineLayout.SIMPLE
}, 'google_translate_element');
}
</script>
<script src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
It is working just fine :) But is there a way to detect the user ip and auto translate when a user go in to my site?
Starting today, Google Translate's camera can automatically detect languages so you can point your camera at a flyer or sign and get results in your native tongue even if you don't know what language you're reading.
On the Review tab, in the Language group, click Language. Click Set Proofing Language. In the Language dialog box, select the Detect language automatically check box. Review the languages shown above the double line in the Mark selected text as list.
Google Translate To use it, copy some text in the unknown language and head to Google Translate. Paste your text in the box on the left. As soon as you do, it should detect the language of the pasted text, showing [Language] - Detected above, and translate to English for you.
Although you can use IP-based location detection (see this answer), but it's neither reliable nor makes you wiser about user's preferred languages (e.g. users travelling abroad, etc.).
Websites with heavy international traffic use various parameters to decide in which language the content should be presented. Some of these parameters:
Accept-Language
HTTP header which is discussed in detail here.window.navigator.language
or window.navigator.userLanguage
(for IE)MediaWiki extension, UniversalLanguageSelector
, uses these factors as well as stored user preferences to provide a list of common languages for each user. See getFrequentLanguageList()
.
W3C also has some recommendations.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With