2017 © Pedro Peláez
 

library translug

Translate Chinese And Then Make It Sluggable

image

jellybool/translug

Translate Chinese And Then Make It Sluggable

  • Friday, July 28, 2017
  • by JellyBool
  • Repository
  • 2 Watchers
  • 112 Stars
  • 8,680 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 14 Forks
  • 1 Open issues
  • 11 Versions
  • 10 % Grown

The README.md

Translug

Build Status Scrutinizer Code Quality Build Status Code Coverage StyleCI Total Downloads Latest Stable Version License, (*1)

来源于 translate 和 slug 这两个词的组合,目的是实现文章和帖子中文标题也可以使用 slug 类型的 url 。, (*2)

Demo

CODECASTS 视频学习社区: https://www.codecasts.com/discuss ,随便点开一个问答帖子就可以看效果。, (*3)

使用前必看

由于有道翻译服务全面升级:http://fanyi.youdao.com/openapi?path=data-mode, (*4)

敬请使用过老版本的用户尽快升级 Translug 2.0 以上。, (*5)

对应的版本说明:, (*6)

Laravel Translu
5.* ~1.0
6.* or 7.* ~2.0
8.* ~3.0

安装

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

composer require jellybool/translug

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

"jellybool/translug" : "~3.0"

然后执行 composer update, (*9)

初始化

在 Translug 中,翻译的功能是直接使用有道翻译 API ,你首先需要在这里注册你的网站或者 App:, (*10)

http://ai.youdao.com/docs/api.s, (*11)

不用担心,非常简单! 有道翻译的免费接口限制为每小时最多 1000 次请求,如果需要更多 API 调用,请联系有道官方。, (*12)

注册之后,需要创建一个应用,然后你会拿到两个关键的信息:, (*13)

1. appKey
2. appSecret

1.Laravel 中使用

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

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

/*  如果你是从 translug:~1.0 升级的话,需要把下面的配置修改成上面的
'youdao' => [
        'key' => env('YOUDAO_API_KEY'),
        'from' => env('YOUDAO_KEY_FROM'),
    ],
 */   

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

YOUDAO_APP_KEY=app_key
YOUDAO_APP_SECRET=app_secret

translug:~1.0 升级的话,也要对应修改这里的 .env 变量, (*16)

config/app.php 中,添加 provideraliases :, (*17)

 //providers
 \JellyBool\Translug\TranslugServiceProvider::class,

// aliases
'Translug' => \JellyBool\Translug\TranslugFacade::class,

1.2 使用, (*18)

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

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

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

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

//或者你只想要 slug 的话

translug('如何安装 Laravel');
//how-to-install-the-laravel

translug('怎么理解 laravel 关联模型');
//how-to-understand-the-laravel-associated-model

//針對繁體,翻譯會有一點不一樣
translug('怎麼理解 laravel 關聯模型');
//how-to-understand-the-laravel-correlation-model

2.在普通的项目使用

2.1 设置 appKey 和 appSecret, (*19)

use JellyBool\Translug\Translug;

$translug = new Translug(['appKey' => 'your_key_from', 'appSerect' => 'your_api_key' ]);
// 或者也可以这样
$translug = new Translug();
$translug->setConfig('appKey' => 'your_key_from', 'appSerect' => 'your_api_key']);

2.2 使用, (*20)

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

$translug->translug('如何安装 Laravel');
//how-to-install-the-laravel

The Versions

28/07 2017

dev-master

9999999-dev

Translate Chinese And Then Make It Sluggable

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar JellyBool

translate slug

28/07 2017

2.0.3

2.0.3.0

Translate Chinese And Then Make It Sluggable

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar JellyBool

translate slug

26/07 2017

v1.0.4

1.0.4.0

Translate Chinese And Then Make It Sluggable

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar JellyBool

translate slug

26/07 2017

2.0.2

2.0.2.0

Translate Chinese And Then Make It Sluggable

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar JellyBool

translate slug

26/07 2017

dev-analysis-8wp1Z9

dev-analysis-8wp1Z9

Translate Chinese And Then Make It Sluggable

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar JellyBool

translate slug

26/05 2017

2.0.1

2.0.1.0

Translate Chinese And Then Make It Sluggable

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar JellyBool

translate slug

20/02 2017

1.0.3

1.0.3.0

Translate Chinese And Then Make It Sluggable

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar JellyBool

translate slug

01/12 2016

dev-JellyBool-patch-1

dev-JellyBool-patch-1

Translate Chinese And Then Make It Sluggable

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar JellyBool

translate slug

18/09 2016

v1.0.2

1.0.2.0

Translate Chinese And Then Make It Sluggable

  Sources   Download

MIT

The Requires

 

by Avatar JellyBool

translate slug

15/09 2016

v1.0.1

1.0.1.0

Translate Chinese And Then Make It Sluggable

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar JellyBool

translate slug

15/09 2016

v1.0

1.0.0.0

Translate Chinese And Then Make It Sluggable

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar JellyBool

translate slug