folklore/laravel-locale is a Laravel package for localization package for laravel 5.
It currently has 3 GitHub stars and 753 downloads on Packagist (latest version v8.0.6).
Install it with composer require folklore/laravel-locale.
Discover more Laravel packages by folklore
or browse all Laravel packages to compare alternatives.
Last updated
A simple localization package for Laravel 5. It provides URL detection, Route parameters, session storage, and view sharing.
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
You can specify the locale of a specific routes:
Route::get('/fr', [
'as' => 'home.fr',
'locale' => 'fr',
function()
{
return view('home');
}
]);
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
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.