Google翻訳インターフェイス


 :<input type="text" id="source" onchange="submitChange()"><br><br>
 :<select id="langpair">
	<option value="zh-CN|en"> </option>
	<option value="en|zh-CN"> </option>

</select>
<br><br>
 :<div id="results_body" style="color: red"></div>

<div class=line></div>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
		google.load("language", "1"); 
		google.setOnLoadCallback(submitChange); 
		function submitChange() { 
			var value = document.getElementById('source').value; 
			var langpair = document.getElementById('langpair'); 
			var pair = langpair.options[langpair.selectedIndex].value.split('|'); 
			var src = pair[0]; var dest = pair[1]; 
			google.language.translate(value, src, dest, translateResult); 
			return false; 
		} 
		function translateResult(result) { 
			var resultBody = document.getElementById("results_body"); 
			if (result.translation) { 
				resultBody.innerHTML = result.translation; 
			} else { 
				resultBody.innerHTML = '';
			}
		}
</script>