PHPackages                             themismin/translate - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. themismin/translate

ActiveLibrary

themismin/translate
===================

一个集成百度翻译，有道翻译，Google 翻译的PHP composer package

v1.0(2y ago)04MITPHP

Since Feb 4Pushed 2y agoCompare

[ Source](https://github.com/themismin/translate)[ Packagist](https://packagist.org/packages/themismin/translate)[ RSS](/packages/themismin-translate/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

Translate for PHP
=================

[](#translate-for-php)

---

[![](https://camo.githubusercontent.com/5c9f02822ab7238d658901207fc988d82a7d8b3f43e4c79fb83d59728c5cc83e/68747470733a2f2f7472617669732d63692e6f72672f5368616f5a654d696e672f7472616e736c6174652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/ShaoZeMing/translate)[![](https://camo.githubusercontent.com/7bbcea600d80856f3eb743acb304652cf0bc25c1c40fbfb0d6f928b21a8a3ee6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f5368616f5a654d696e672f7472616e736c6174652e737667)](https://packagist.org/packages/shaozeming/translate)[![](https://camo.githubusercontent.com/03a51343aab0694d26c09e2e1d4f8691158e10f362ce0454c0fdfbf7156a756a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f5368616f5a654d696e672f7472616e736c6174652e737667)](https://packagist.org/packages/stichoza/shaozeming/translate)

Installing
----------

[](#installing)

```
$ composer require shaozeming/translate -v
```

### configuration

[](#configuration)

```
// config/translate.php

    //使用什么翻译驱动
    // 目前支持这几种: "baidu", "youdao","google"
    /*
     *  默认使用google  google使用的是免费接口爬取，目前能用，为了确保稳定，请配置一个备用服务， 目前只有google和baidu 支持繁体翻译
     */
    'defaults' => [
        'driver' => 'google',   //默认使用google翻译
        'spare_driver' => 'baidu',  // 备用翻译api ,第一个翻译失败情况下，调用备用翻译服务，填写备用翻译api 需要在下面对应的drivers中配置你参数
        'from' => 'zh',   //原文本语言类型 ，目前支持：auto【自动检测】,en【英语】,zh【中文】，jp【日语】,ko【韩语】，fr【法语】，ru【俄文】，pt【西班牙】
        'to' => 'en',     //翻译文本 ：en【英语】,zh【中文】，jp【日语】,ko【韩语】，fr【法语】，ru【俄文】，pt【西班牙】,
    ],

       'drivers' => [
           'baidu' => [
               'base_url' => 'http://api.fanyi.baidu.com/api/trans/vip/translate',
               //App id of the translation api
               'app_id' => '20180611000174972',
               //secret of the translation api
               'app_key' => 'cEXha7w4elaXO23NJ2Tt',
           ],

           'youdao' => [
               'base_url' => 'https://openapi.youdao.com/api',
               //App id of the translation api
               'app_id' => '',
               //secret of the translation api
               'app_key' => '',
           ],

           'google' => [
               'base_url' => 'http://translate.google.cn/translate_a/single',
               'app_id' => '',
               'app_key' => '',
           ],
       ],
```

Usage
-----

[](#usage)

```
use ShaoZeMing\Translate\TranslateService;

$config = include($youerpath.'/translate.php')

$obj = new TranslateService($config);
$result = $obj->translate('你知道我对你不仅仅是喜欢');
print_r($result);

```

Example:

```
 // 动态更改翻译服务商
 $config = include($youerpath.'/translate.php')
 $obj = new TranslateService($config);
 $obj->setDriver('baidu')->translate('你知道我对你不仅仅是喜欢');
 print_r($result);
 //You know I'm not just like you

 // 动态更改语种

 $from = 'en';
 $to = 'zh';
 $result =  $obj->setDriver('baidu')->setFromAndTo($from,$to)->translate('I love you.');
print_r($result);
```

License
-------

[](#license)

MIT

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 86.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

834d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8c800de9c17265b0c85ee3c8e2be6f196b2dfb0c0a5692f5d7ca9e8ee6064df2?d=identicon)[themismin](/maintainers/themismin)

---

Top Contributors

[![ShaoZeMing](https://avatars.githubusercontent.com/u/19376576?v=4)](https://github.com/ShaoZeMing "ShaoZeMing (13 commits)")[![themismin](https://avatars.githubusercontent.com/u/5857863?v=4)](https://github.com/themismin "themismin (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/themismin-translate/health.svg)

```
[![Health](https://phpackages.com/badges/themismin-translate/health.svg)](https://phpackages.com/packages/themismin-translate)
```

###  Alternatives

[tanmuhittin/laravel-google-translate

Translate translation files to other languages using google translate api

4312.2M11](/packages/tanmuhittin-laravel-google-translate)[devaslanphp/auto-translate

Auto generate translation JSON files

6623.1k](/packages/devaslanphp-auto-translate)[web64/laravel-nlp

Laravel package for accessing NLP tools

5711.2k](/packages/web64-laravel-nlp)[hpolthof/laravel-translations-db

A database translations implementation for Laravel 5.

545.8k](/packages/hpolthof-laravel-translations-db)[enupal/translate

Translate your website templates and plugins into multiple languages. Bulk translation with Google Translate or Yandex.

1172.1k](/packages/enupal-translate)[mmoreram/translation-server

PHP translation server

233.7k2](/packages/mmoreram-translation-server)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
