This Nova tool allows you to:
- Add a language switcher to the header of the Nova application
- Handle language switching and cache the current locale across multiple browsers
- Switch the application direction for RTL-supported languages
- PHP: >=8.0
- Laravel Nova: ^4.0|^5.0
Note: This package is not compatible with Nova 3
- Add multiple languages from the configuration
- Remember locale settings using cache (no database table required)
- Auto-inject language switcher to the application header
- Easy 4-step setup
| English | Arabic |
|---|---|
![]() |
![]() |
Install the Nova tool via Composer:
composer require badinansoft/nova-language-switchRegister the tool in app/Providers/NovaServiceProvider.php:
public function tools()
{
return [
// ...
new \Badinansoft\LanguageSwitch\LanguageSwitch(),
];
}Register the middleware in app/Http/Kernel.php:
protected $middlewareGroups = [
'web' => [
// ...
\Badinansoft\LanguageSwitch\Http\Middleware\LanguageSwitch::class
],
];Register the tool in app/Providers/NovaServiceProvider.php (same as Laravel 10):
public function tools()
{
return [
// ...
new \Badinansoft\LanguageSwitch\LanguageSwitch(),
];
}Register the middleware in bootstrap/app.php:
->withMiddleware(function (Middleware $middleware) {
$middleware->web(append: [
\Badinansoft\LanguageSwitch\Http\Middleware\LanguageSwitch::class,
]);
})Publish the configuration file:
php artisan vendor:publish --provider="Badinansoft\LanguageSwitch\ToolServiceProvider" --tag="config"Edit the published config file (config/language-switch.php):
return [
/**
* Supported languages for your application
* @var array<string, string>
*/
'supported-languages' => [
'en' => 'English',
'ar' => 'Arabic',
// Add or remove languages as needed
],
/**
* Languages that require RTL support
* @var array<string>
*/
'rtl-languages' => [
'ar'
// Add other RTL language codes
],
];The MIT License (MIT). Please see License File for more information.

