Are your admins asking for multi-language support? Do they want a language switcher, to enjoy using their dashboard in their preferred...
Are your admins asking for multi-language support? Do they want a language switcher, to enjoy using their dashboard in their preferred language? Last question! Have you ever noticed a language switcher in our demo?
Yes, we have it as a free package - it's been available for a couple of months. And you can use it site-wide as well! Not only on the Backpack admin panel.
composer require backpack/language-switcher
config/backpack/base.php
:'middleware_class' => [
...
\Backpack\LanguageSwitcher\Http\Middleware\LanguageSwitcherMiddleware::class,
],
Optionally, you may add the middleware to the web, api or other middleware groups where you may want to use the language switcher in app/Http/Kernel.php.
topbar_right_content.blade.php
or wherever you need it:// resources/views/vendor/backpack/theme-tabler/inc/topbar_right_content.blade.php
@include('backpack.language-switcher::language-switcher')
config/backpack/crud.php
'locales' => [
'en' => 'English',
'pt' => 'Portuguese',
'ro' => 'Romanian',
...
There you can set the array of locales your app uses. Keep in mind the default locale of your app should remain in config.app.locale and config.app.fallback_locale.
Done! It's placed & working in your admin panel.
If you wish to use the language switcher on other parts of your app, add the middleware in app/Http/Kernel.php
. For instance, you can enable this for the whole web middleware group, or the api.
protected $middlewareGroups = [
'web' => [
...
\Backpack\LanguageSwitcher\Http\Middleware\LanguageSwitcherMiddleware::class,
],
Here, You discovered a language switcher package for your Laravel app. Use it in the Backpack admin panel or your website front, 5 minutes of effort is enough to understand and use. Thanks for reading.
Happy Language Switching✌️😎
Subscribe to our "Article Digest". We'll send you a list of the new articles, every week, month or quarter - your choice.
What do you think about this?
Wondering what our community has been up to?