PHP code example of prunacatalin / filament-locale-switcher
1. Go to this page and download the library: Download prunacatalin/filament-locale-switcher library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
prunacatalin / filament-locale-switcher example snippets
return [
'locales' => ['en', 'ro', 'fr', 'it'],
'labels' => [
'en' => 'English',
'ro' => 'Română',
'fr' => 'Français',
'it' => 'Italiano',
],
'flags' => [
'en' => '🇬🇧',
'ro' => '🇷🇴',
'fr' => '🇫🇷',
'it' => '🇮🇹',
],
'persist' => 'user', // session | user | cookie
'user_column' => 'locale', // column on User when persist=user
'placement' => 'topbar', // topbar | user-menu | both
'topbar_offset' => '4.5rem', // CSS gap between switcher and user-menu
];
use Prunacatalin\FilamentLocaleSwitcher\Http\Middleware\ApplyLocale;
use Prunacatalin\FilamentLocaleSwitcher\LocaleSwitchPlugin;
public function panel(Panel $panel): Panel
{
return $panel
// …your usual config…
->plugin(LocaleSwitchPlugin::make())
->middleware([
// …default Filament middleware (EncryptCookies, StartSession, …)…
ApplyLocale::class,
]);
}
$panel->plugin(
LocaleSwitchPlugin::make()
->locales(['en', 'de']) // narrower than the global list
->persist('cookie') // override global persist
->placement('user-menu'), // override global placement
);