Download the PHP package tool-mountain/laravel-uri-translator without Composer
On this page you can find all versions of the php package tool-mountain/laravel-uri-translator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tool-mountain/laravel-uri-translator
More information about tool-mountain/laravel-uri-translator
Files in tool-mountain/laravel-uri-translator
Package laravel-uri-translator
Short Description Translate a URI or individual slugs.
License MIT
Informations about the package laravel-uri-translator
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
- PHP >= 8.1
- Laravel >= 10.0
📦 Install
Install this package with Composer:
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.
Return an array of translations from the routes.php
files.
🚀 Usage
Use the Lang::uri()
macro when registering routes:
The URI macro accepts 2 additional parameters:
- A locale, in case you need translations to a locale other than the current app locale.
- A namespace, in case your translation files reside in a package.
You can also use trans()->uri('hello/world')
instead of Lang::uri('hello/world')
.
🔌 Example
Using these example translations:
These are possible translation results:
🚧 Testing
☕️ Credits
🔒 Security
If you discover any security related issues, please e-mail me instead of using the issue tracker.
📑 Changelog
A complete list of all notable changes to this package can be found on the releases page.
📜 License
The MIT License (MIT). Please see License File for more information.