免费谷歌翻译api

作者: dreamfly 分类: php 发布时间: 2020-04-22 23:21

我们知道对于国际语言的翻译,谷歌做的还是很优秀的,但是因为某些原因,国内无法使用谷歌云来进行翻译,所以我们需要一种可以通过不需要授权请求api的方式,这个时候,php-google-sdk可以方便我们实现这个功能。

使用方式

安装

composer require stichoza/google-translate-php

引入class


use Stichoza\GoogleTranslate\TranslateClient;

创建请求对象

$tr=new TranslateClient();

设置国内请求url

$tr->setUrlBase('http://translate.google.cn/translate_a/single');

设置翻译源语言,目的语言

$tr->setSource('en'); 
$tr->setTarget('ka');

翻译句子

echo $tr->translate('Hello World!');

链式操作

echo $tr->setSource('en')->setTarget('ka')->translate('Goodbye');

设置代理

$tr->setHttpOption(['proxy'=>'tcp://localhost:8090']);

批量翻译

echo $tr->translate(['I can dance', 'I like trains', 'Double rainbow']);

注意事项
此函数库只供学习交流使用,如果频繁请求,可能会导致谷歌封禁ip。

如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!

9条评论
  • ValfKeeli

    2022年7月29日 05:53

    Cialis On Line Pharmacies cheapest cialis online Buy Synthroid Cheap Online

  • Obedoms

    2022年8月18日 02:46

    Propecia Propiedades ivermectin tablets online Acquista Cialis

  • Haintailk

    2022年9月1日 06:15

    After single oral-dose administration, the maximum observed plasma concentration Cmax of tadalafil is achieved between 2 and 8 hours median time of 4 hours is cialis generic Erectile dysfunction can be caused by physical, psychological, and lifestyle factors, so the condition is complicated to treat

  • optonse

    2022年9月3日 10:09

    Get started today to see if one of these proven, FDA-approved erectile dysfunction drugs could help reignite your sex life priligy fda approval All Upguys products are dispensed from UPRX facility in Burnaby, BC

  • Issueks

    2022年9月5日 08:14

    We can help you find the best meds offers and pharmacy reviews fast and easy in order to get you the most affordable and quality Cialis generics for your health needs cialis generic online There is also some variation amongst brands of tablets, so it can take time to get to the point where a ciali is completely effective and is effective without oral medication

  • absotatot

    2022年9月7日 10:41

    Dosage 20 MG cialis generic cost Importantly, IIEF-EF domain scores normalized 26 in 41 and 32 of men treated with daily dose therapy compared with none after the on-demand phase

  • autolla

    2022年9月10日 08:12

    Julia rosalind schwendinger died at ivi. what does clomid do for men

  • mumClulky

    2022年9月13日 10:31

  • idionmelm

    2022年9月17日 01:24

    doxycycline take with food The period of life between birth and 2 years is important for the development of eating habits and to shape infants preferences.

发表评论

您的电子邮箱地址不会被公开。