plugins-world/translate 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

plugins-world/translate

最新稳定版本:v4.0.0

Composer 安装命令:

composer require plugins-world/translate

包简介

An extension package that supports multi platform translation, such as Baidu translation, Google translation, Jinshan translation and Youdao translation

README 文档

README

Latest Stable Version Total Downloads Latest Unstable Version License PHP Version Require

项目自动拆分,如需跟踪源码更新情况,请前往:https://github.com/plugins-world/packages 查看 Translate 目录

安装

$ composer require "plugins-world/translate" -vvv

使用

<?php

require __DIR__ . '/vendor/autoload.php';

// deepl
// $app = new \Plugins\Translate\Translator\Deepl([
//     // 需要配置代理
//     'is_use_pro_api' => 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

统计信息

  • 总下载量: 61
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 97
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 97
  • Watchers: 2
  • Forks: 14
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-04-29