PHPackages                             cdo9/laravel-uri-translator - 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. [Localization &amp; i18n](/categories/localization)
4. /
5. cdo9/laravel-uri-translator

ActiveLibrary[Localization &amp; i18n](/categories/localization)

cdo9/laravel-uri-translator
===========================

Translate a URI or individual slugs.

5.0.3(1mo ago)011—0%1MITPHPPHP ^8.1

Since Oct 7Pushed 1mo agoCompare

[ Source](https://github.com/cdo9/laravel-uri-translator)[ Packagist](https://packagist.org/packages/cdo9/laravel-uri-translator)[ Fund](https://paypal.me/ivanvermeyen)[ Fund](https://ko-fi.com/ivanvermeyen)[ RSS](/packages/cdo9-laravel-uri-translator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (6)Versions (4)Used By (1)

Laravel URI Translator
======================

[](#laravel-uri-translator)

[![GitHub release](https://camo.githubusercontent.com/e56983daba96a5f392926c4f961fcdc06d5ac52a485c818b67a1b8ceeaba8623/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f636f64657a65726f2d62652f6c61726176656c2d7572692d7472616e736c61746f722e7376673f7374796c653d666c61742d737175617265)](https://github.com/codezero-be/laravel-uri-translator/releases)[![Laravel](https://camo.githubusercontent.com/50a632fed10f91ccd009337654743ad6ba9321cdcd796352dca02b3c296fc702/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c61726176656c2d31322d7265643f7374796c653d666c61742d737175617265266c6f676f3d6c61726176656c266c6f676f436f6c6f723d7768697465)](https://laravel.com)[![License](https://camo.githubusercontent.com/cc4361d29b4c264a9451be771d2865cbdab236ebc8d92c1e62118e2540062d70/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f636f64657a65726f2f6c61726176656c2d7572692d7472616e736c61746f722e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/f550633e423011a302d67b04339d0be5c5706dea984f3a28b3d199439820f6df/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f636f64657a65726f2d62652f6c61726176656c2d7572692d7472616e736c61746f722f72756e2d74657374732e796d6c3f7374796c653d666c61742d737175617265266c6f676f3d676974687562266c6f676f436f6c6f723d7768697465266c6162656c3d7465737473)](https://github.com/codezero-be/laravel-uri-translator/actions)[![Code Coverage](https://camo.githubusercontent.com/78e89c1ad8469f4ace57a3f0309760eb0be487e3db78484c4934223bf97a3ce2/68747470733a2f2f696d672e736869656c64732e696f2f636f646163792f636f7665726167652f61643666636561313532623434396433383061313837613337356430663764372f6d61737465723f7374796c653d666c61742d737175617265)](https://app.codacy.com/gh/codezero-be/laravel-uri-translator)[![Code Quality](https://camo.githubusercontent.com/6106bc0032e3320ebb072a28619125231fb9bc023a393f8006470aff67ae4114/68747470733a2f2f696d672e736869656c64732e696f2f636f646163792f67726164652f61643666636561313532623434396433383061313837613337356430663764372f6d61737465723f7374796c653d666c61742d737175617265)](https://app.codacy.com/gh/codezero-be/laravel-uri-translator)[![Total Downloads](https://camo.githubusercontent.com/d684eeddc89523674d101faf3734751c247b19d148e994c04b1d30ddfc469b17/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f636f64657a65726f2f6c61726176656c2d7572692d7472616e736c61746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/codezero/laravel-uri-translator)

[![ko-fi](https://camo.githubusercontent.com/1fedf764fa06114b797ee53e7506df10880abed6766f854202d758df1707969d/68747470733a2f2f7777772e6b6f2d66692e636f6d2f696d672f676974687562627574746f6e5f736d2e737667)](https://ko-fi.com/R6R3UQ8V)

This package registers a macro for the Laravel `Translator` class. This will allow you to translate individual URI slugs, while ignoring parameter placeholders.

Parameters will not be translated by this macro. That remains the responsibility of your code.

✅ Requirements
--------------

[](#-requirements)

- PHP &gt;= 8.1
- Laravel &gt;= 10.0

📦 Install
---------

[](#-install)

Install this package with Composer:

```
composer require codezero/laravel-uri-translator
```

Laravel will automatically register the ServiceProvider.

In your app's `lang` folder, create subdirectories for every locale you want to have translations for.

Next create a `routes.php` file in each of those directories.

```
lang/
  ├── en/
  │    └── routes.php
  └── nl/
       └── routes.php

```

Return an array of translations from the `routes.php` files.

### 🚀 Usage

[](#-usage)

Use the `Lang::uri()` macro when registering routes:

```
Route::get(Lang::uri('hello/world'), [Controller::class, 'index']);
```

The URI macro accepts 2 additional parameters:

1. A locale, in case you need translations to a locale other than the current app locale.
2. A namespace, in case your translation files reside in a package.

```
Lang::uri('hello/world', 'fr', 'my-package');
```

You can also use `trans()->uri('hello/world')` instead of `Lang::uri('hello/world')`.

### 🔌 Example

[](#-example)

Using these example translations:

```
// lang/nl/routes.php
return [
    'hello' => 'hallo',
    'world' => 'wereld',
    'override/hello/world' => 'something/very/different',
    'hello/world/{parameter}' => 'uri/with/{parameter}',
];
```

These are possible translation results:

```
// Translate every slug individually
// Translates to: 'hallo/wereld'
Lang::uri('hello/world');

// Keep original slug when missing translation
// Translates to: 'hallo/big/wereld'
Lang::uri('hello/big/world');

// Translate slugs, but not parameter placeholders
// Translates to: 'hallo/{world}'
Lang::uri('hello/{world}');

// Translate full URIs if an exact translation exists
// Translates to: 'something/very/different'
Lang::uri('override/hello/world');

// Translate full URIs if an exact translation exists (with placeholder)
// Translates to: 'uri/with/{parameter}'
Lang::uri('hello/world/{parameter}');
```

🚧 Testing
---------

[](#-testing)

```
composer test
```

☕️ Credits
----------

[](#️-credits)

- [Ivan Vermeyen](https://github.com/ivanvermeyen)
- [All contributors](https://github.com/codezero-be/laravel-uri-translator/contributors)

🔒 Security
----------

[](#-security)

If you discover any security related issues, please [e-mail me](mailto:ivan@codezero.be) instead of using the issue tracker.

📑 Changelog
-----------

[](#-changelog)

A complete list of all notable changes to this package can be found on the [releases page](https://github.com/codezero-be/laravel-uri-translator/releases).

📜 License
---------

[](#-license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance92

Actively maintained with recent releases

Popularity6

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 57.1% 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 ~90 days

Total

3

Last Release

37d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5ffd1d6768342609ec647d13b27f823c923454b83ec8967843d05bcdfd4427c4?d=identicon)[cdo9](/maintainers/cdo9)

---

Top Contributors

[![ivanvermeyen](https://avatars.githubusercontent.com/u/3598622?v=4)](https://github.com/ivanvermeyen "ivanvermeyen (4 commits)")[![cdo9](https://avatars.githubusercontent.com/u/5813412?v=4)](https://github.com/cdo9 "cdo9 (3 commits)")

---

Tags

urluriphplaravellocalizationlanguagelocalecountryslugs

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/cdo9-laravel-uri-translator/health.svg)

```
[![Health](https://phpackages.com/badges/cdo9-laravel-uri-translator/health.svg)](https://phpackages.com/packages/cdo9-laravel-uri-translator)
```

###  Alternatives

[codezero/laravel-localized-routes

A convenient way to set up, manage and use localized routes in a Laravel app.

543638.1k4](/packages/codezero-laravel-localized-routes)[codezero/laravel-localizer

Automatically detect and set an app locale that matches your visitor's preference.

50394.3k4](/packages/codezero-laravel-localizer)[opgginc/codezero-laravel-localized-routes

A convenient way to set up, manage and use localized routes in a Laravel app.

2770.1k1](/packages/opgginc-codezero-laravel-localized-routes)[awes-io/localization-helper

Package for convenient work with Laravel's localization features

3527.1k4](/packages/awes-io-localization-helper)[vluzrmos/language-detector

Detect the language for your application using browser preferences, subdomains or route prefixes.

109554.8k3](/packages/vluzrmos-language-detector)[longman/laravel-multilang

Package to integrate multi language (multi locale) functionality in Laravel 5.x

5514.4k1](/packages/longman-laravel-multilang)

PHPackages © 2026

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