mouyong / translate
An extension package that supports multi platform translation, such as Baidu translation, Google translation, Jinshan translation and Youdao translation
Installs: 755
Dependents: 1
Suggesters: 0
Security: 0
Stars: 94
Watchers: 2
Forks: 13
Open Issues: 1
Requires
- php: >=8.0
- stichoza/google-translate-php: ^5.1
- symfony/http-client: ^6.0
Requires (Dev)
README
项目自动拆分,如需跟踪源码更新情况,请前往:https://github.com/plugins-world/packages 查看 Translate 目录
安装
$ composer require "mouyong/translate" -vvv
使用
<?php require __DIR__ . '/vendor/autoload.php'; // jinshan // $app = new \MouYong\Translate\Translator\Jinshan(); // baidu // $app = new \MouYong\Translate\Translator\Baidu([ // // @see http://api.fanyi.baidu.com/manage/developer // // 'app_id' => '你的百度翻译 app_id', // // 'app_key' => '你的百度翻译 app_key', // ]); // youdao // $app = new \MouYong\Translate\Translator\Youdao([ // // @see https://ai.youdao.com/console/ // // 'app_id' => '你的有道智云 app_id', // // 'app_key' => '你的有道智云 app_key', // ]); // google // $app = new \MouYong\Translate\Translator\Google\Google([ // // 需要配置代理 // 'http' => [ // 'proxy' => [ // 'http' => 'http://10.0.30.3:7890', // 'https' => 'http://10.0.30.3:7890', // ] // ], // ]); // try { // $result = $app->translate('测试', 'zh', 'en'); // var_dump($result->getSrc(), $result->getDst(), $result->getOriginal()); // } catch (\Throwable $e) { // var_dump($e->getMessage()); // } // die; // 文本内容探测:检测用户输入的内容是哪个国家的语言 $languageRecognizerClient = new \MouYong\Translate\LanguageRecognizer\LanguageRecognizerClient(); $languageRecognizer = $languageRecognizerClient->detect("Словѣ́ньскъ/ⰔⰎⰑⰂⰡⰐⰠⰔⰍⰟ"); var_dump($languageRecognizer->getData());
TODO
[ ] Deepl
[ ] Bing
[ ] Tencent