laravel-lang-switcher maintained by lopatin96
Description
Laravel lang switcher
Author
Last update
2025/02/16 14:01
(dev-master)
License
Downloads
9 025
Install
Publish config
php artisan vendor:publish --tag="laravel-lang-switcher-config"
Add language code and names to the config config/laravel-lang-switcher.php:
'languages' => [
'en' => 'English',
'ru' => 'русский',
]
Include lang-switcher anywhere you want, for example in your footer:
@include('laravel-lang-switcher::lang-switcher.index')
// or
@include('laravel-lang-switcher::lang-switcher.index', ['align' => 'right'])
Add LangSwitcher middleware to middleware array in app/Http/Kernel.php:
protected $middleware = [
…
\Atin\LaravelLangSwitcher\Http\Middleware\LangSwitcher::class,
];
Publish images
php artisan vendor:publish --tag="laravel-lang-switcher-images"
Trait
Add HasLocale trait to User model
use Atin\LaravelLangSwitcher\Traits\HasLocale;
class User extends Authenticatable
{
use HasLocale, …
Images
Set of images https://flagicons.lipis.dev
Migrations
Run migrations:
php artisan migrate
Publishing
Migrations
php artisan vendor:publish --tag="laravel-lang-switcher-migrations"
Localization
php artisan vendor:publish --tag="laravel-lang-switcher-lang"
Views
php artisan vendor:publish --tag="laravel-lang-switcher-views"
Images
php artisan vendor:publish --tag="laravel-lang-switcher-images"
Config
php artisan vendor:publish --tag="laravel-lang-switcher-config"