PHPackages                             imnpc/laravel-slug - 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. imnpc/laravel-slug

ActiveLibrary

imnpc/laravel-slug
==================

laravel - translate Chinese to en for slug with baidu、youdao or pinyin

1.1.0(6mo ago)04MITPHP

Since Nov 4Pushed 6mo agoCompare

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

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

Slug
====

[](#slug)

[![Latest Stable Version](https://camo.githubusercontent.com/0a7ff045eb527603c4fa4b33f8988da1a094aa1be99fc2877cd3402c9deebe09/68747470733a2f2f706f7365722e707567782e6f72672f6a6f7572646f6e2f736c75672f762f737461626c65)](https://packagist.org/packages/jourdon/slug)[![Total Downloads](https://camo.githubusercontent.com/527e21b024d63e1cee7dad5460fd43d21c84cf1c675732bf48304578c2ad081d/68747470733a2f2f706f7365722e707567782e6f72672f6a6f7572646f6e2f736c75672f646f776e6c6f616473)](https://packagist.org/packages/jourdon/slug)[![License](https://camo.githubusercontent.com/dbdcb63bf61279f95764ed9366d416711f030d2804e1e0561dd83de87778f86e/68747470733a2f2f706f7365722e707567782e6f72672f6a6f7572646f6e2f736c75672f6c6963656e7365)](https://packagist.org/packages/jourdon/slug)

说明
--

[](#说明)

Slug 整合了百度翻译与有道翻译,你可以选择使用其中一个平台来实现翻译的功能,当然，如果翻译失败的情况下，我们还有备用的方案，可以转换成拼音。

使用这个安装包的前提是你需要在这两个平台注册并申请应用：

-
-

你需要拿到这两个关键信息:

1. app ID
2. app Secret

安装
--

[](#安装)

使用 Composer 安装:

```
composer require imnpc/slug
```

导出配置文件

```
php artisan vendor:publish --provider="Jourdon\Slug\SlugServiceProvider"
```

配置文件内容如下：

```
return [
    //翻译类型只有两种 "baidu", "youdao"

    'type'  =>  env('TRANSLATE_TYPE','baidu'),

    //翻译 API 地址
    'api' => [
        'baidu' =>  'http://api.fanyi.baidu.com/api/trans/vip/translate?',
        'youdao'=>  'https://openapi.youdao.com/api?'
    ],

    //App id
    'translate_appid' => env('TRANSLATE_APPID',''),

    //APP secret
    'translate_secret'   => env('TRANSLATE_SECRET',''),
];
```

接下来，你需要在 `.env` 文件中添加:

```
TRANSLATE_TYPE= baidu
TRANSLATE_APPID=
TRANSLATE_SECRET=
```

将你在平台注册得到的信息添进去即可，当然，`TRANSLATE_TYPE` 这里是你注册平台

> **重点**：如果没有导出配置，或者env 文件中配置项没有正确填写，会默认转成拼音

在 `config/app.php`的 `providers`数组中加入

```
\Jourdon\Slug\SlugServiceProvider::class,
```

在 `config/app.php`的 `aliases`数组中加入

```
'Slug'  => \Jourdon\Slug\Slug::class,

```

> 如果你使用的是 `laravel 5.5` 版本以上，那面上面的两步可以忽略。

使用
--

[](#使用)

```
use Slug;

Slug::translate('php是世界上最好的语言');
//php-is-the-best-language-in-the-world
```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance68

Regular maintenance activity

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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

Every ~0 days

Total

2

Last Release

188d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4f149dfb0fcbc9e73b835450b3b2bd4e1b732e0d2113f519705b22f95913acae?d=identicon)[imnpc](/maintainers/imnpc)

---

Top Contributors

[![imnpc](https://avatars.githubusercontent.com/u/5801647?v=4)](https://github.com/imnpc "imnpc (3 commits)")

---

Tags

sluglaraveltranslateLaravel-Slugpingyin

### Embed Badge

![Health badge](/badges/imnpc-laravel-slug/health.svg)

```
[![Health](https://phpackages.com/badges/imnpc-laravel-slug/health.svg)](https://phpackages.com/packages/imnpc-laravel-slug)
```

###  Alternatives

[jellybool/translug

Translate Chinese And Then Make It Sluggable

14845.7k](/packages/jellybool-translug)[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13704.6k2](/packages/ralphjsmit-laravel-helpers)[aurawindsurfing/google-translate

Free Laravel package for Paid Google Translate REST API with your own API key

1119.5k1](/packages/aurawindsurfing-google-translate)

PHPackages © 2026

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