一、Google翻譯API介面
Google翻譯API介面可以讓你的應用程序實現自動翻譯功能,只需要調用API介面即可得到翻譯結果。
在使用API介面之前,需要先申請一個Google Cloud賬號,並激活Google翻譯API服務。接著,你就可以通過API Key來調用Google翻譯API介面了。
//引用Google翻譯API介面: import com.google.cloud.translate.Translate; import com.google.cloud.translate.Translate.TranslateOption; import com.google.cloud.translate.TranslateOptions; import com.google.cloud.translate.Translation; //初始化API Key TranslateOptions options = TranslateOptions.newBuilder() .setApiKey("YOUR_API_KEY") .build(); Translate translate = options.getService(); //翻譯文本 Translation translation = translate.translate( "Hello World!", TranslateOption.sourceLanguage("en"), TranslateOption.targetLanguage("zh-CN")); System.out.printf("Text: %s%n", translation.getTranslatedText());
二、Google翻譯API使用授權
在使用Google翻譯API之前,需要在Google Cloud Console中先創建一個項目,並獲取API Key和OAuth2.0認證。API Key用於訪問API介面,OAuth2.0認證則用於授權訪問。
在創建OAuth2.0認證之前,需要先創建一個Web應用,並在應用中創建客戶端ID和客戶端密碼。這些信息將在OAuth2.0認證中使用。
//Google認證選項 GoogleAuthorizationCodeFlow authFlow = new GoogleAuthorizationCodeFlow.Builder( new NetHttpTransport(), GsonFactory.getDefaultInstance(), CLIENT_ID, CLIENT_SECRET, TRANSLATE_SCOPE).build(); //獲取Authorization URL String authorizationUrl = authFlow.newAuthorizationUrl().setRedirectUri(REDIRECT_URI).build(); //獲取授權碼(code) String code = request.getParameter("code"); //獲取AccessToken GoogleTokenResponse tokenResponse = authFlow.newTokenRequest(code).setRedirectUri(REDIRECT_URI).execute(); GoogleCredential credential = new GoogleCredential.Builder().setTransport(new NetHttpTransport()) .setJsonFactory(new JacksonFactory()) .setClientSecrets(CLIENT_ID, CLIENT_SECRET) .build().setAccessToken(tokenResponse.getAccessToken()) .setRefreshToken(tokenResponse.getRefreshToken());
三、Google翻譯APP下載
Google翻譯APP可以讓你隨時隨地進行翻譯服務,支持多種語言,甚至包括拍照翻譯、語音翻譯等高級功能。
你可以在Google Play Store或蘋果App Store中搜索「Google翻譯」進行下載安裝。
四、Google翻譯下載
除了在線使用Google翻譯服務之外,你還可以下載Google翻譯離線包,這樣即使沒有網路也可以進行翻譯。
下載地址:https://translate.google.cn/about/intl/zh-CN_ALL_offline.html
五、Google翻譯官網網頁
你可以訪問Google翻譯官網的網頁版本進行翻譯服務。網頁端支持多種語言,包括中文、英文、日語、法語等。
網址:https://translate.google.cn/
六、Google翻譯2
Google翻譯2是一款更快、更準確的Google翻譯工具,最新版本支持多種語言,能夠實現實時翻譯、語音翻譯等高級功能。
你可以在Google Play Store或蘋果App Store中搜索「Google翻譯2」進行下載安裝。
七、Google翻譯通
Google翻譯通是一款專業的翻譯工具,支持多種語言,能夠實現文本翻譯、語音翻譯、圖片翻譯等多種翻譯方式。
你可以在Google Play Store或蘋果App Store中搜索「Google翻譯通」進行下載安裝。
八、Google翻譯官網
Google翻譯官網是Google翻譯的官方網站,提供Google翻譯的最新消息、幫助文檔等信息。
網址:https://translate.google.cn/about/intl/zh-CN_ALL/
九、Google雲翻譯API密鑰
Google雲翻譯API密鑰是將Google翻譯服務集成到自己的應用程序中的必要步驟。在獲取API密鑰之後,你可以使用API介面來實現自動翻譯功能。
獲取API密鑰的步驟如下:
- 前往Google Cloud Console,創建一個項目並啟用API
- 前往API管理頁,啟用Google翻譯API服務
- 前往「憑據」頁面,創建一個API密鑰
- 將API密鑰複製到自己的應用程序中,即可調用Google翻譯API介面了
十、Google翻譯官方下載
你可以在Google官網上下載Google翻譯的安裝包,支持Windows、Mac OS、Linux等多個平台。
下載地址:https://www.google.com/chrome/?brand=CHBD&SPR=translate
原創文章,作者:QGPI,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/142598.html