PHPackages                             jourdon/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. jourdon/slug

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

jourdon/slug
============

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

1.0(8y ago)2020361MITPHP

Since Apr 20Pushed 7y ago1 watchersCompare

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

READMEChangelogDependencies (2)Versions (2)Used By (1)

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 jourdon/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

32

—

LowBetter than 69% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity63

Established project with proven stability

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

2994d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/24295670?v=4)[jourdon](/maintainers/jourdon)[@jourdon](https://github.com/jourdon)

### Embed Badge

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

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

###  Alternatives

[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.3k543.5M2.5k](/packages/aws-aws-sdk-php)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k656.1k37](/packages/neuron-core-neuron-ai)[google/cloud-core

Google Cloud PHP shared dependency, providing functionality useful to all components.

346132.9M111](/packages/google-cloud-core)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3741.3M46](/packages/tencentcloud-tencentcloud-sdk-php)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

751291.4k39](/packages/civicrm-civicrm-core)[spatie/laravel-export

Create a static site bundle from a Laravel app

674146.0k6](/packages/spatie-laravel-export)

PHPackages © 2026

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