PHPackages                             tool-mountain/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. tool-mountain/laravel-uri-translator

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

tool-mountain/laravel-uri-translator
====================================

Translate a URI or individual slugs.

1.0.0(1y ago)11.4k↓33.3%1MITPHPPHP ^8.1CI passing

Since Mar 31Pushed 1y ago1 watchersCompare

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

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

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

[](#laravel-uri-translator)

[![GitHub release](https://camo.githubusercontent.com/2ce497e56791e51fd5e8251df6bc29894a618de2959e747ddf83563336352d71/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f746f6f6c2d6d6f756e7461696e2f6c61726176656c2d7572692d7472616e736c61746f722e7376673f7374796c653d666c61742d737175617265)](https://github.com/tool-mountain/laravel-uri-translator/releases)[![Laravel](https://camo.githubusercontent.com/50a632fed10f91ccd009337654743ad6ba9321cdcd796352dca02b3c296fc702/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c61726176656c2d31322d7265643f7374796c653d666c61742d737175617265266c6f676f3d6c61726176656c266c6f676f436f6c6f723d7768697465)](https://laravel.com)[![License](https://camo.githubusercontent.com/ce4061232480533d0aa259cadd7c883a399bef22a75996fe248b725631b40e6b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f746f6f6c2d6d6f756e7461696e2f6c61726176656c2d7572692d7472616e736c61746f722e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/902d3183bf671364ea97ba0d50acdf5a7dd262868486ad4b118e5f96b1db0805/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f746f6f6c2d6d6f756e7461696e2f6c61726176656c2d7572692d7472616e736c61746f722f72756e2d74657374732e796d6c3f7374796c653d666c61742d737175617265266c6f676f3d676974687562266c6f676f436f6c6f723d7768697465266c6162656c3d7465737473)](https://github.com/tool-mountain/laravel-uri-translator/actions)[![Codecov](https://camo.githubusercontent.com/e2e9df4d19cf38545880f49c37e2e19187e5cb88c98e17a683dae2fe13e70b43/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f746f6f6c2d6d6f756e7461696e2f6c61726176656c2d7572692d7472616e736c61746f723f7374796c653d666c61742d737175617265)](https://codecov.io/gh/tool-mountain/laravel-uri-translator)[![Total Downloads](https://camo.githubusercontent.com/d82ba973abdef50c82b5c4fbcc7450e3f9046d3cac5388b585dd88213c078d5f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f746f6f6c2d6d6f756e7461696e2f6c61726176656c2d7572692d7472616e736c61746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tool-mountain/laravel-uri-translator)

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 tool-mountain/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) [†](https://github.com/codezero-be/laravel-uri-translator/pull/2#issuecomment-2747179649)
- [All contributors](https://github.com/tool-mountain/laravel-uri-translator/contributors)

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

[](#-security)

If you discover any security related issues, please [e-mail me](mailto:roj@vroe.men) 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/tool-mountain/laravel-uri-translator/releases).

📜 License
---------

[](#-license)

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

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance46

Moderate activity, may be stable

Popularity19

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

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

406d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a5dc56de17326e155210bbdbc689759955974cb97f9a91642169748e3b837584?d=identicon)[Rojtjo](/maintainers/Rojtjo)

---

Top Contributors

[![rojtjo](https://avatars.githubusercontent.com/u/1123887?v=4)](https://github.com/rojtjo "rojtjo (35 commits)")[![ivanvermeyen](https://avatars.githubusercontent.com/u/3598622?v=4)](https://github.com/ivanvermeyen "ivanvermeyen (4 commits)")

---

Tags

urluriphplaravellocalizationlanguagelocalecountryslugs

###  Code Quality

TestsPHPUnit

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/tool-mountain-laravel-uri-translator/health.svg)](https://phpackages.com/packages/tool-mountain-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)
