All Projects → JellyBool → Translug

JellyBool / Translug

Licence: mit
中文的 url slug 支持

Projects that are alternatives of or similar to Translug

Eloquent Sluggable
Easy creation of slugs for your Eloquent models in Laravel
Stars: ✭ 3,321 (+2190.34%)
Mutual labels:  laravel, slug
Nova Slug Field
Slug field for Laravel Nova
Stars: ✭ 131 (-9.66%)
Mutual labels:  laravel, slug
Laravel Hashslug
Package providing a trait to use Hashids on a model
Stars: ✭ 136 (-6.21%)
Mutual labels:  laravel, slug
Gh Actions Yaml Generator
Ghygen is a GitHub Actions configurator for your Laravel Application.
Stars: ✭ 142 (-2.07%)
Mutual labels:  laravel
Laravel Passport Social Grant
🔒 API authentication via social networks for your Laravel application
Stars: ✭ 142 (-2.07%)
Mutual labels:  laravel
Laravel Awesome
Laravel 学习图谱
Stars: ✭ 143 (-1.38%)
Mutual labels:  laravel
Awesome
A collection of awesome Statamic articles, links, resources and other rad things.
Stars: ✭ 144 (-0.69%)
Mutual labels:  laravel
Ladmin
EasyLms is a development management system with Laravel
Stars: ✭ 141 (-2.76%)
Mutual labels:  laravel
Laravel Auth0
Laravel plugin for Auth0
Stars: ✭ 143 (-1.38%)
Mutual labels:  laravel
Bkash
PHP client for bKash Payment Gateway API
Stars: ✭ 143 (-1.38%)
Mutual labels:  laravel
Neontsunami Laravel
Source for my website and blog
Stars: ✭ 142 (-2.07%)
Mutual labels:  laravel
Lqycms
基于laravel框架的企业级开源cms管理系统,开源php商城源码,B2C微商城系统,企业建站cms。
Stars: ✭ 142 (-2.07%)
Mutual labels:  laravel
Laravel Postmark
A Postmark adapter for Laravel
Stars: ✭ 143 (-1.38%)
Mutual labels:  laravel
Laravel Scaffold
The base for developing awesome projects
Stars: ✭ 142 (-2.07%)
Mutual labels:  laravel
Laravel Themer
Multi theme support for Laravel application
Stars: ✭ 142 (-2.07%)
Mutual labels:  laravel
Laravel Commentable
Stars: ✭ 141 (-2.76%)
Mutual labels:  laravel
Youtube
Upload a video to a single YouTube channel with Laravel 5.
Stars: ✭ 143 (-1.38%)
Mutual labels:  laravel
Localization
🌐 Localization package for Laravel
Stars: ✭ 142 (-2.07%)
Mutual labels:  laravel
Validation
🔒 Laravel farsi/persian validation
Stars: ✭ 142 (-2.07%)
Mutual labels:  laravel
Laravel Paket
Composer GUI. Manage Laravel dependencies from web interface without switching to command line!
Stars: ✭ 143 (-1.38%)
Mutual labels:  laravel

Translug

Build Status Scrutinizer Code Quality Build Status Code Coverage StyleCI Total Downloads Latest Stable Version License

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

Demo

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

使用前必看

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

敬请使用过老版本的用户尽快升级 Translug 2.0 以上。

对应的版本说明:

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

安装

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

composer require jellybool/translug

或者在你的 composer.json 文件中添加:

"jellybool/translug" : "~3.0"

然后执行 composer update

初始化

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

http://ai.youdao.com/docs/api.s

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

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

1. appKey
2. appSecret

1.Laravel 中使用

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

  '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 文件中添加:

YOUDAO_APP_KEY=app_key
YOUDAO_APP_SECRET=app_secret

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

config/app.php 中,添加 provideraliases :

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

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

1.2 使用

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

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 使用

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

$translug->translug('如何安装 Laravel');
//how-to-install-the-laravel
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].