Google – Cloud Translation API

发布时间 2023-10-15 20:09:49作者: 兴杰

前言

通常网站内容翻译,我们都不推荐使用 Google Translate。但网站中一些不那么重要的内容确实可以用 Google Translate。比如 Customer Reviews。

这篇是续 

Google Maps Embed API & JavaScript API

Google – Reviews

YouTube Data API

又一篇关于 Google Cloud API 的教程。请大家先看完上面几篇,因为教过的内容我是不重复的。

 

参考

Docs – Cloud Translation

 

v2 basic 和 v3 advanced 版本

Google Translate API 有两个版本。v2 是旧的,v3 是新的。

我估计 v2 会被完全淘汰掉,所以这篇只会教 v3 而已。

2 个点要说一下:

第一、v2 和 v3 的 API 接口完全不同。

第二、v2 只需要 API Keys 就可以使用了,v3 却一定要 OAuth 才能使用。

 

Setup

和 Google Reviews、YouTube Data API 类似。

1. Google Cloud Account(要绑定信用卡哦)

2. Google Cloud Project

3. Enable Cloud Translation API

4. OAuth(App, Client id, Client secret),不需要 API Keys 哦。

5. Login by Google Account with scopes:

https://www.googleapis.com/auth/cloud-platform

https://www.googleapis.com/auth/cloud-translation