mikehins / language-switcher
Create a language switcher for your Laravel 5.5 app, straight from the command line
Installs: 853
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 2
Forks: 1
Open Issues: 2
Type:plugin
pkg:composer/mikehins/language-switcher
This package is auto-updated.
Last update: 2025-10-05 16:35:18 UTC
README
Laravel 7 ready
language-switcher
Create a language switcher for your Laravel 5.5+ app straight from the command line
composer require mikehins/language-switcher
This command will add / remove a language switcher menu item in the main nav bar.
Important Laravel version 6 +
Be sure to run composer require laravel/ui and php artisan ui vue --auth before to run the command. You also have to run npm install && npm run dev
Important before Laravel version 6.0
Be sure to run php artisan make:auth and php artisan migrate before to run the command
To add the language switcher
php artisan switch:add
To revert the changes
php artisan switch:delete
This is what the command switch:add does :
- Add a
default_languagefield in your users table - Add the markup to the
layouts/app.blade.phpfile - Add a route in the
routes/web.phpfile - Add a Middleware inside
app\Http\Middleware - Add the middleware to the
app\Http\Kernel.php - Add a LanguageController in the
app\Http\Controllersdirectory - Add a language file to the config directory
config/languages.php
When the user switch the language, it will automatically update the default_language field from the users table.
The next time the user logs in, the language session will automatically be set by the middleware using the auth()->user()->default_language variable.
