PHPackages                             beautinow/translug - 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. beautinow/translug

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

beautinow/translug
==================

Translate Chinese And Then Make It Sluggable

v3.0.2(4y ago)033MITPHPPHP ^7.2|^8.0

Since Sep 15Pushed 4y agoCompare

[ Source](https://github.com/Beautinow/translug)[ Packagist](https://packagist.org/packages/beautinow/translug)[ RSS](/packages/beautinow-translug/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (3)Versions (15)Used By (0)

Translug
========

[](#translug)

[![Build Status](https://camo.githubusercontent.com/a577336dd102ba3333aff55d6b865de941ae8d54efe32812a7dc52264d662d0c/68747470733a2f2f7472617669732d63692e6f72672f4a656c6c79426f6f6c2f7472616e736c75672e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/JellyBool/translug)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/47d227987dc010b52f70521508ad8d912b7240e4b6b6dc05a9a4b8bfc098916e/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4a656c6c79426f6f6c2f7472616e736c75672f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/JellyBool/translug/?branch=master)[![Build Status](https://camo.githubusercontent.com/2cff710fc567b974461be3bb49bb12b9c03e80457efd3ee32a5383f1fa6d6d9b/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4a656c6c79426f6f6c2f7472616e736c75672f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/JellyBool/translug/build-status/master)[![Code Coverage](https://camo.githubusercontent.com/b952136ef113e98661943090494b040a9c7fbff1730c492dd028687a42bd0095/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4a656c6c79426f6f6c2f7472616e736c75672f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/JellyBool/translug/?branch=master)[![StyleCI](https://camo.githubusercontent.com/894214c01b4b8a192f88bd8c0e29dcd46e9a458385388cdd1ed9cba18802f009/68747470733a2f2f7374796c6563692e696f2f7265706f732f36383330303132382f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/68300128)[![Total Downloads](https://camo.githubusercontent.com/048ab0d59119d43567b7efe864ae04c964fff6460809f39883e37d9039995d80/68747470733a2f2f706f7365722e707567782e6f72672f4a656c6c79426f6f6c2f7472616e736c75672f646f776e6c6f616473)](https://packagist.org/packages/JellyBool/translug)[![Latest Stable Version](https://camo.githubusercontent.com/227d170ec783538911b9f4e3c30d320106cd2557f44e4c207a3d005918bf14b1/68747470733a2f2f706f7365722e707567782e6f72672f4a656c6c79426f6f6c2f7472616e736c75672f76657273696f6e)](https://packagist.org/packages/JellyBool/translug)[![License](https://camo.githubusercontent.com/dc3bcc044d9b03b8aade2bf6471d8b7c86330654355e84e79530ee4214f0c817/68747470733a2f2f706f7365722e707567782e6f72672f4a656c6c79426f6f6c2f7472616e736c75672f6c6963656e7365)](https://packagist.org/packages/JellyBool/translug)

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

Demo
----

[](#demo)

CODECASTS 视频学习社区:  ,随便点开一个问答帖子就可以看效果。

使用前必看
-----

[](#使用前必看)

由于有道翻译服务全面升级：

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

对应的版本说明：

LaravelTranslu5.\*~1.06.\* or 7.\*~2.08.\*~3.0安装
--

[](#安装)

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

```
composer require jellybool/translug
```

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

```
"jellybool/translug" : "~3.0"
```

然后执行 `composer update`

初始化
---

[](#初始化)

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

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

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

```
1. appKey
2. appSecret

```

### 1.Laravel 中使用

[](#1laravel-中使用)

**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` 中,添加 `provider` 和 `aliases` :

```
 //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在普通的项目使用)

**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
```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity76

Established project with proven stability

 Bus Factor1

Top contributor holds 94% 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 ~158 days

Recently: every ~356 days

Total

12

Last Release

1782d ago

Major Versions

v1.0.3 → 2.0.12017-05-26

v1.0.4 → 2.0.32017-07-28

2.0.5 → 3.0.12021-02-27

PHP version history (4 changes)v1.0.3PHP &gt;=5.5.9

2.0.5PHP ^7.2

3.0.1PHP ^7.25|^8.0

v3.0.2PHP ^7.2|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/70b21e6b484c6002743ff4f2fe205cdeac6934cbac45161418a05e97dd0063f9?d=identicon)[HarriesChen](/maintainers/HarriesChen)

---

Top Contributors

[![JellyBool](https://avatars.githubusercontent.com/u/6011686?v=4)](https://github.com/JellyBool "JellyBool (47 commits)")[![HarriesCC](https://avatars.githubusercontent.com/u/70427383?v=4)](https://github.com/HarriesCC "HarriesCC (2 commits)")[![summerblue](https://avatars.githubusercontent.com/u/324764?v=4)](https://github.com/summerblue "summerblue (1 commits)")

---

Tags

slugtranslate

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/beautinow-translug/health.svg)

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

###  Alternatives

[jellybool/translug

Translate Chinese And Then Make It Sluggable

14845.7k](/packages/jellybool-translug)[bensampo/laravel-embed

Painless responsive embeds for videos, slideshows and more.

142146.8k](/packages/bensampo-laravel-embed)[glhd/conveyor-belt

14797.0k](/packages/glhd-conveyor-belt)[pulkitjalan/ip-geolocation

IP Geolocation Wrapper with Laravel Support

89164.9k1](/packages/pulkitjalan-ip-geolocation)[adrianorosa/laravel-geolocation

Laravel Geo Location package to get details for a given IP Address

6593.3k1](/packages/adrianorosa-laravel-geolocation)[bakame/laravel-domain-parser

Laravel package to integrate PHP Domain parser.

26534.8k4](/packages/bakame-laravel-domain-parser)

PHPackages © 2026

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