$18.89

Does anyone know of any automatic translation widgets I could use on my site?

Ask a question+
1

I’m looking for a widget or an html code I could put on a weebly page, so it can translate the page based on the users computer language or ip address

Mr J 5
add comment

1 Answer

1

You could do something similar to this:

<!DOCTYPE html>
<html lang="en-US">
<body>
<p>paragraph</p>
<div id="google_translate_element"></div>
<script type="text/javascript">
function googleTranslateElementInit() {
  new google.translate.TranslateElement({pageLanguage: 'en'}, 'google_translate_element');
}
</script>
<script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
</body>
</html>

However this means they will have to choose their language.
In the<html lang = "en-US"> you could create a function that determines the language of the computer.
I think javascript would work best for that something like this:

var language = window.navigator.userLanguage || window.navigator.language;
alert(language);
DredF 10
add comment

Your Answer