Google Translate tools uses the APIS provided by goolge to write a translation tool,CodeIt is easy to run as follows:
Download Google Translate API: http://code.google.com/p/google-api-for-dotnet/ from Google's official website
The translation code is as follows:
Create a new ANSI PHP file, and then make a class:
Copy Code code as follows:
Header ("content-type:text/html; Charset=utf-8 ");
Class google_api_translator{
Public $opts = Array ("text" => "", "Language_pair" => "En|it");
Public $out = "";
function Setopts ($opts) {
if ($opts ["text"]!= "") $this->opts["Text" = $opts ["text"];
if ($opts ["Language_pair"]!= "") $this->opts["Language_pair"] = $opts ["Language_pair"];
}
function translate
/* Google Translate PHP interface* Official Written 2009-03-28* http://blog.csdn.net/aprin/* Note: If the translated text is UTF-8 encoded, delete the Mb_convert_encoding function*/Class Google_api_translator {Public $url = "http://translate.google.com/translate_t";Public $text = "";//Translated textPublic $out = ""; Translation outputfunction SetText ($text) {$this->text = $text;}function
1, the installation of related modules
Pip Install--upgrade Google-cloud
Or
Pip Install--upgrade google-cloud-translate
2, before invoking the API for translation, you need to install the relevant certificate
The official website provides the method to have three kinds: 1, installs the Google Cloud SDK downloadi
A translation function is used in the project, that is, after the translation is submitted to Google, the returned results are obtained.
First, find out the context of Google translation:Request Processing
After submitting the translation, check what the request and response are:
VcHLzOG9u7XEVVJMPC9zdHJvbmc + PC9wPgo8cD48L3A + CjxwcmUgY2xhc3M9 "brush: java;"> url = httl: // translate.google.cn/translate_a/t
Google code: Insert after meta name="google-translate-customization" content="4bd8dffe75af5007-16fa37f088724895-g08c0457d35008bb8-47">meta>and insert the following code where you want the button to appear:Bing Code:div id=' Microsofttranslatorwidget ' class=' light ' style =' color:white;background-color: #555555 '>div>script type=' Text/javascript '>SetTimeou
Easily integrate Google Translate into your web App with jquery.1. [Code][javascript] Code?1?2 [Code]loadscript, setting the path?? 1LoadScript (ScriptPath + "jquery-blockui.js");2LoadScript (ScriptPath + "jquery.translate-1.4.7.min.js");3LoadScript (ScriptPath + "jquery.cookie.js");? 3.Code [JavaScript] Code01function Getscriptspath () {Scripts var = document.getelementsbytagname ("script");The var regex =
C # implement Google Translate API,
Since Google Translate's official API is a paid version, in the spirit of free and open source, share the code for implementing Google Translate API with C. This code is very simple, mainly divided into two parts: request content through W
Method a direct translation and pronunciation
1 Open the browser, enter "g.cn" in the Address bar, and click the "Translate" link at the bottom:
2 or directly in the address bar input Google translated URL http://translate.google.cn, access to Google translation interface:
3 directly enter or paste text into the left text edit box:
Description
1. Use Google translation services to obtain translations and voice;
2. Use MPlayer to play the resulting sound file, so if you want to play the voice, make sure that the MPlayer program is found in path, and if there is no mplayer, set the Use_tts to False to run. That
Main (Use_tts=false)
3. Exit the program, enter "X" and return.
Copy the Code code as follows:
#! /usr/bin/env python
#coding =utf-8
Import requests
def
PHP Code:
Copy Code code as follows:
#!/usr/bin/php-q
/**
* PHP Script for Google Translate
* @author: Yishan Wang
* @version: 1.0.0
*/
Class Google_api_translator
{
Public $url = "http://translate.google.com/translate_t";
Public $text = "";
Public $out = "";
Public $ip = ';
function SetText ($text) {
$this->text = $text;
}
function translate
1. First note that the first word in the English sentence should be capitalized,2. End of sentence, use a full period.3. English words and the preceding punctuation to leave a space, such as: you. is should be you. Is you .....4. In English as the main translation language, translated into other languages, the translation of the results of the translation into Chinese, judge whether the statement is fluent. -----This is the key.Use Google to
Today I found Google's translation tool is very useful, you go to http://translate.google.com/translate_tools? Hl = en SL = ZH-CN, select the language in which your webpage is used, and the corresponding
Code . For example, if you select Chinese Simplified, the following code is generated:
Script SRC
=
"
Http://www.gmodules.com/ig/ifr? Url = http://www.google.com/ig/modules/translatemypage.xmlup_source_language=zh-CNw=160h=60title=border=output=js
"
>
Script
>
put it in
Python is very fun .. It took 5 to 6 hours. Based on some examples on the internet, I wrote a Google Translate desktop version. The interface and functions are simple and can only be translated between Chinese and English. Mainly to learn Python
It is very convenient to use Glade on the interface. After painting, you only need to link the signal, and glade with pygtk is very convenient.
The source code of
Open Google Translate (http://translate.google.cn/) Input
ニマビ、ニマビ、ニシダシャビ。シャンブチヤ、シャンブチ。ヨムヨア、ヨムヨ
Select Japanese as the source language! Then click the pronunciation! Sorry!
==================================
Input
にまびあにまび,さんぶちあさんぶち,さんぶちああああああ,よむよよむよ
Select Japanese! Click to pronounce!
======================================
Input
หนี่มาบี หนี่มาบี หนี่สื้อด้าส่าบี ซางบู้ฉี่อย่าซางบู้ฉี่ โหย่มู่โหย่อาโหย่มู่โ
The solution is to go to my computer or computer on the desktop, find C:/Windows/System32/drivers/etc/hosts, and use notepad to open the hosts file;Add the following two lines (there must be a space between the IP address and the URL ):203.208.46.145 translate.google.com203.208.46.145 translate.googleapis.comClick "file" rarr; "Save ".Restart the browser to see if the translation is correct,In addition to this method, we can try to open g.cn and click "
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.