https://github.com/plugins-world/Translate
文本语言识别,文本内容翻译,集成百度翻译、有道云翻译、谷歌翻译、金山词霸翻译
https://github.com/plugins-world/Translate
laravel php translate
Last synced: 11 months ago
JSON representation
文本语言识别,文本内容翻译,集成百度翻译、有道云翻译、谷歌翻译、金山词霸翻译
- Host: GitHub
- URL: https://github.com/plugins-world/Translate
- Owner: plugins-world
- License: lgpl-3.0
- Created: 2018-07-16T13:35:26.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2025-03-26T02:03:57.000Z (about 1 year ago)
- Last Synced: 2025-04-30T23:35:12.408Z (11 months ago)
- Topics: laravel, php, translate
- Language: PHP
- Homepage:
- Size: 63.5 KB
- Stars: 96
- Watchers: 2
- Forks: 16
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
多平台翻译、文本语言探测
---
[](https://packagist.org/packages/plugins-world/translate) [](https://packagist.org/packages/plugins-world/translate) [](https://packagist.org/packages/plugins-world/translate) [](https://packagist.org/packages/plugins-world/translate) [](https://packagist.org/packages/plugins-world/translate)
项目自动拆分,如需跟踪源码更新情况,请前往:https://github.com/plugins-world/packages 查看 Translate 目录
# 安装
```shell
$ composer require "plugins-world/translate" -vvv
```
# 使用
```php
false,
// 'pro_app_key' => '',
// 'free_app_key' => '',
// 'is_enable_proxy' => true,
// 'http_proxy' => 'http://10.0.50.101:7890',
// 'http_proxys' => 'http://10.0.50.101:7890',
// ]);
// google
// $app = new \Plugins\Translate\Translator\Google([
// // 需要配置代理
// 'is_enable_proxy' => true,
// 'http_proxy' => 'http://10.0.50.101:7890',
// 'https_proxy' => 'http://10.0.50.101:7890',
// // 如需要重新定义 http options,在此配置
// 'http' => [
// 'timeout' => 5.0,
// 'verify' => false,
// ],
// ]);
// baidu
// $app = new \Plugins\Translate\Translator\Baidu([
// // @see http://api.fanyi.baidu.com/manage/developer
// // 'app_id' => '你的百度翻译 app_id',
// // 'app_key' => '你的百度翻译 app_key',
// ]);
// youdao
// $app = new \Plugins\Translate\Translator\Youdao([
// // @see https://ai.youdao.com/console/
// // 'app_id' => '你的有道智云 app_id',
// // 'app_key' => '你的有道智云 app_key',
// ]);
// jinshan
// 金山翻译无法使用,验证时间 2024-04-29 21:56:00
// $app = new \Plugins\Translate\Translator\Jinshan();
// try {
// $result = $app->translate('测试', 'zh', 'en');
// var_dump($result->getSrc(), $result->getDst(), $result->getOriginal());
// } catch (\Throwable $e) {
// var_dump($e->getMessage());
// }
// die;
// 文本内容探测:检测用户输入的内容是哪个国家的语言
$languageRecognizerClient = new \Plugins\Translate\LanguageRecognizer\LanguageRecognizerClient();
$languageRecognizer = $languageRecognizerClient->detect("Словѣ́ньскъ/ⰔⰎⰑⰂⰡⰐⰠⰔⰍⰟ");
var_dump($languageRecognizer->getData());
```
## TODO
[x] Deepl
[ ] Bing
[ ] Tencent