Download the PHP package mputkowski/laravel-localization without Composer
On this page you can find all versions of the php package mputkowski/laravel-localization. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mputkowski/laravel-localization
More information about mputkowski/laravel-localization
Files in mputkowski/laravel-localization
Package laravel-localization
Short Description Powerful Localization for Laravel
License MIT
Informations about the package laravel-localization
Laravel Localization
Localization for Laravel
Installation
| L6 | L7 | L8 | L9 | L10 | L11 | L12 | |
|---|---|---|---|---|---|---|---|
| v4 | ✓ | ✓ | ✓ | ✓ | ✗ | ✗ | ✗ |
| v5 | ✗ | ✗ | ✗ | ✓ | ✓ | ✓ | ✓ |
Add package to composer.json
Publish package's config file
Laravel 11 or newer
Append the middleware to the web group in the bootstrap/app.php:
Laravel 10 or older
Include middleware within the web group in middlewareGroups array (app/Http/Kernel.php):
You don't have to register service provider and alias, this package uses Package Auto-Discovery.
Configuration
Configuration is stored in config/localization.php file.
| Key | Type | Default |
|---|---|---|
| auto | bool | true |
| cookie_name | string | lang |
| default_locale | string | en |
| Route | ||
| enabled | bool | true |
| pattern | string | /lang/{lang} |
Auto-detection
If auto is set to true, the app will automatically detect client's language. The lang directory will be compared with the client's Accept-Language header. If header doesn't match with the app's locales, language will be set to default.
Auto-detected language could be changed by accessing a special route designed for that, or by calling the setLocale method:
Route
This package also provides routes for quick language change (url: /lang/{lang}, example /lang/en).
Contributing
Feel free to create pull requests or open issues, I'll look on them as quick as I can.
License
This project is open-sourced software licensed under the MIT license.
All versions of laravel-localization with dependencies
illuminate/cookie Version ^9.0|^10.0|^11.0|^12.0
illuminate/support Version ^9.0|^10.0|^11.0|^12.0