https://github.com/craft-forge/filament-language-switcher
Zero-config language switcher for Filament admin panels. Automatically scans available translations, renders dropdown with country flags, persists selection via sessions.
https://github.com/craft-forge/filament-language-switcher
filament i18n language-switch language-switcher laravel localization php
Last synced: 5 months ago
JSON representation
Zero-config language switcher for Filament admin panels. Automatically scans available translations, renders dropdown with country flags, persists selection via sessions.
- Host: GitHub
- URL: https://github.com/craft-forge/filament-language-switcher
- Owner: craft-forge
- License: mit
- Created: 2025-09-11T22:30:51.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-09-16T11:55:35.000Z (9 months ago)
- Last Synced: 2025-09-22T15:37:49.506Z (9 months ago)
- Topics: filament, i18n, language-switch, language-switcher, laravel, localization, php
- Language: PHP
- Homepage: https://packagist.org/packages/craft-forge/filament-language-switcher
- Size: 367 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Filament Language Switcher
A simple and elegant language switcher plugin for Filament admin panels. Automatically detects available Filament translations or allows custom language configuration with optional flag icons.


## Installation
| Plugin Version | Filament Version | PHP Version |
|----------------|------------------|-------------|
| 1.x | 3.x, 4.x, 5.x | \> 8.1 |
Install the package via Composer:
```bash
composer require craft-forge/filament-language-switcher
```
## Usage
Register the plugin in your Filament panel configuration: (e.g. `AdminPanelProvider`).
```php
use CraftForge\FilamentLanguageSwitcher\FilamentLanguageSwitcherPlugin;
use Filament\Panel;
public function panel(Panel $panel): Panel
{
return $panel
// ...
->plugins([
FilamentLanguageSwitcherPlugin::make(),
]);
}
```
The plugin will automatically detect available Filament language files and display them in a dropdown menu.
## Configuration
### Custom Languages
Define your own language list instead of auto-detection:
```php
FilamentLanguageSwitcherPlugin::make()
->locales([
['code' => 'en', 'name' => 'English', 'flag' => 'gb'],
['code' => 'uk', 'name' => 'Українська', 'flag' => 'ua'],
['code' => 'de', 'name' => 'Deutsch', 'flag' => 'de'],
])
```
The `name` and `flag` parameters are optional. When omitted, the plugin automatically generates them from its built-in language dictionary:
```php
FilamentLanguageSwitcherPlugin::make()
->locales([
['code' => 'en', 'flag' => 'us'],
['code' => 'fr'],
['code' => 'de'],
])
```
For flag codes, please refer to https://flagicons.lipis.dev (e.g., pl for Poland).

### Hide Flags
Display only language codes and names without flag icons:
```php
FilamentLanguageSwitcherPlugin::make()
->showFlags(false)
```

### Custom Render Hook
Change where the language switcher appears in your panel:
```php
use Filament\View\PanelsRenderHook;
FilamentLanguageSwitcherPlugin::make()
->renderHook(PanelsRenderHook::USER_MENU_PROFILE_AFTER)
```
Available render hooks: https://filamentphp.com/docs/4.x/advanced/render-hooks#panel-builder-render-hooks

## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.