folklore/laravel-locale
Laravel Locale
A simple localization package for Laravel 5. It provides URL detection, Route parameters, session storage, and view sharing.
Installation
Dependencies:
Version prior to 3.0
Version 3.0 and up
Installation:
1- Require the package via Composer in your composer.json.
{
"require": {
"folklore/laravel-locale": "~3.0"
}
}
2- Run Composer to install or update the new requirement.
$ composer install
or
$ composer update
3- Add the service provider to your app/config/app.php file
\Folklore\LaravelLocale\LocaleServiceProvider::class,
5- Publish the configuration file
$ php artisan vendor:publish --provider="Folklore\LaravelLocale\LocaleServiceProvider"
6- Review the configuration file
config/locale.php
Usage
Define route locale
You can specify the locale of a specific routes:
Route::get('/fr', [
'as' => 'home.fr',
'locale' => 'fr',
function()
{
return view('home');
}
]);
Auto-detection from URL
It is possible to let the package auto-detect the locale from the first part fo the URL.
Route::get('/fr/a-propos', [
'as' => 'about.fr',
function()
{
return view('home');
}
]);
Be sure to add the supported locales in config/locale.php
View sharing
By default, this package shares two variables to every views $locale and $otherLocales. The $otherLocales variable is an array containing all the other locales than the current one.
Related Packages
A convenient way to set up, manage and use localized routes in a Laravel app.
Package to integrate multi language (multi locale) functionality in Laravel 5.x
Laravel 4 and 5 package to add localization capabilities to Eloquent Models
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| v8.0.6 | ^7.3| | 8.*| | MIT | |
| v8.0.5 | ^7.3| | 8.*| | MIT | |
| v8.0.4 | ^7.3| | 8.*| | MIT | |
| v8.0.3 | ^7.3| | 8.*| | MIT | |
| v8.0.2 | ^7.3| | 8.*| | MIT | |
| v8.0.1 | ^7.3| | 8.*| | MIT | |
| v8.0.0 | ^7.3| | 8.* | MIT | |
| v3.0.2 | >=7.0.0 | 5.5.*| | MIT | |
| v3.0.1 | >=7.0.0 | 5.5.*| | MIT | |
| v3.0.0 | >=7.0.0 | 5.5.*| | MIT | |
| v2.2.5 | >=5.5.9 | 5.1.*| | MIT | |
| v2.2.4 | >=5.5.9 | 5.1.*| | MIT | |
| v2.2.3 | >=5.5.9 | 5.1.*| | MIT | |
| v2.2.2 | >=5.5.9 | 5.1.*| | MIT | |
| v2.2.1 | >=5.5.9 | 5.1.*| | MIT | |
| v2.2.0 | >=5.5.9 | 5.1.*| | MIT | |
| v2.1.3 | >=5.5.9 | 5.2.*| | MIT | |
| v2.1.2 | >=5.5.9 | 5.2.*| | MIT | |
| v2.1.1 | >=5.5.9 | 5.2.*| | MIT | |
| v2.1.0 | >=5.5.9 | 5.2.*| | MIT | |
| v2.0.3 | >=5.5.9 | 5.2.*| | MIT | |
| v2.0.2 | >=5.5.9 | 5.2.* | MIT | |
| v2.0.1 | >=5.5.9 | 5.2.* | MIT | |
| v2.0.0 | >=5.5.9 | 5.2.* | MIT | |
| v1.0.0 | >=5.5.9 | 5.1.* | MIT |
