2017 © Pedro Peláez
 

library trans

Translate chinese into english and used for slug

image

miyayeh/trans

Translate chinese into english and used for slug

  • Wednesday, July 25, 2018
  • by lilili001
  • Repository
  • 1 Watchers
  • 0 Stars
  • 8 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 10 Versions
  • 0 % Grown

The README.md

BdTranslug

通过百度翻译api,实现文章和帖子中文标题也可以使用 slug 类型的 url 。, (*1)

使用前必看

使用百度翻译api,http://api.fanyi.baidu.com/api/trans/product/index 使用之前需开通百度通用翻译api权限,并获取appkey和secret., (*2)

每月翻译字符数低于200万,享免费服务,如果更多翻译的需求,请联系百度翻译官方, (*3)

安装

这是一个标准的 Composer 的包,你可以直接通过下面的命令行来安装:, (*4)

composer require miyayeh/trans

或者在你的 composer.json 文件中添加:, (*5)

"miyayeh/trans" : "~1.0"

然后执行 composer update, (*6)

1.Laravel 中使用

1.1 配置 默认情况在,在 laravel 项目中的 config/services.php 中添加:, (*7)

  'stripe' => [
        'model' => App\User::class,
        'key' => env('STRIPE_KEY'),
        'secret' => env('STRIPE_SECRET'),
    ],
   // 下面是你添加的内容
   'youdao' => [
           'appKey' => env('YOUDAO_APP_KEY'),
           'appSecret' => env('YOUDAO_APP_SECRET'),
       ],

'baidutrans' => [
        'appKey' => env('BAIDU_APPID'),
        'appSecret' => env('BAIDU_APP_SECRET')
    ]   

当然,你还需要在 .env 文件中添加:, (*8)

BAIDU_APPID=app_key
BAIDU_APP_SECRET=app_secret

config/app.php 中,添加 provideraliases (laravel 5.5及以上,可略过此步骤):, (*9)

 //providers
 \MiyaYeh\Trans\BdTransServiceProvider::class

// aliases
"BdTrans" => \MiyaYeh\Trans\Facades\BdTransFacade::class

1.2 使用, (*10)

app('BdTrans')->translate('如何安装 Laravel'); 
//How to install the Laravel

// or 
use BdTrans;
BdTrans::translate('如何安装 Laravel');
//How to install the Laravel

app('BdTrans')->slug('如何安装 Laravel'); 
//how-to-install-the-laravel

// or 
use Translug;
BdTrans::slug('如何安装 Laravel');
//how-to-install-the-laravel

The Versions

25/07 2018

dev-master

9999999-dev

Translate chinese into english and used for slug

  Sources   Download

MIT

by Avatar lilili001

translate slug

25/07 2018

1.1.7

1.1.7.0

Translate chinese into english and used for slug

  Sources   Download

MIT

by Avatar lilili001

translate slug

25/07 2018

1.1.6

1.1.6.0

Translate chinese into english and used for slug

  Sources   Download

MIT

by Avatar lilili001

translate slug

25/07 2018

1.1.5

1.1.5.0

Translate chinese into english and used for slug

  Sources   Download

MIT

by Avatar lilili001

translate slug

25/07 2018

1.1.4

1.1.4.0

Translate chinese into english and used for slug

  Sources   Download

MIT

by Avatar lilili001

translate slug

25/07 2018

1.1.3

1.1.3.0

Translate chinese into english and used for slug

  Sources   Download

MIT

by Avatar lilili001

translate slug

25/07 2018

1.1.2

1.1.2.0

Translate chinese into english and used for slug

  Sources   Download

MIT

by Avatar lilili001

translate slug

25/07 2018

1.1.1

1.1.1.0

Translate chinese into english and used for slug

  Sources   Download

MIT

by Avatar lilili001

translate slug

25/07 2018

v1.0.0

1.0.0.0

Translate chinese into english and used for slug

  Sources   Download

MIT

by Avatar lilili001

translate slug

25/07 2018

1.1.0

1.1.0.0

Translate chinese into english and used for slug

  Sources   Download

MIT

by Avatar lilili001

translate slug