google云翻译api客户端库
google-cloud-translate的Python项目详细描述
使用Google Cloud Translation,您可以在 成千上万的语言对。google云翻译api允许网站 程序以编程方式与google云翻译集成。谷歌 云翻译作为付费服务提供。见Pricing和 FAQ页了解详细信息。
快速启动
要使用此库,首先需要执行以下步骤:
- Select or create a Cloud Platform project.
- Enable billing for your project.
- Enable the Google Cloud Translate API.
- Setup Authentication.
安装
使用pip在virtualenv中安装此库。virtualenv是 创建独立的python环境。它解决的基本问题是 依赖项和版本,以及间接权限。
使用virtualenv,无需系统即可安装此库 安装权限,且不会与已安装的系统发生冲突 依赖关系。
支持的python版本
python=3.5
不推荐的python版本
python==2.7。Python2.7支持将于2020年1月1日取消。
Mac/Linux
pip install virtualenv
virtualenv <your-env>
source <your-env>/bin/activate
<your-env>/bin/pip install google-cloud-translate
窗口
pip install virtualenv
virtualenv <your-env>
<your-env>\Scripts\activate
<your-env>\Scripts\pip.exe install google-cloud-translate
示例用法
>>>fromgoogle.cloudimporttranslate>>>client=translate.Client()>>>client.get_languages()[{'language':'af','name':'Afrikaans',},...]>>>client.detect_language(['Me llamo','I am'])[{'confidence':0.25830904,'input':'Me llamo','language':'es',},{'confidence':0.17112699,'input':'I am','language':'en',},]>>>fromgoogle.cloudimporttranslate>>>client=translate.Client()>>>client.translate('koszula'){'translatedText':'shirt','detectedSourceLanguage':'pl','input':'koszula',}