Multi-language Filament implementation with three translation components: Core Filament files, Core Laravel files, and custom additions. Lithuanian language example included with translations in /lang folder and a Filament package for language switching.
We use a [bezhansalleh/filament-language-switch](https://filamentphp.com/plugins/bezhansalleh-language-switch)
package to add a language switcher to the top navigation.
All language files are published.
php artisan lang:publishphp artisan vendor:publish --tag=filament-panels-translations
We set available languages in the AppServiceProvider
.
app/Providers/AppServiceProvider.php:
use BezhanSalleh\LanguageSwitch\LanguageSwitch; public function boot(): void{ LanguageSwitch::configureUsing(function (LanguageSwitch $switch) { $switch ->locales(['lt','en']); });}
In the Resource, we use the translateLabel()
method to translate labels. It makes, for example, Title
to a __('Title')
.