variety of premium plugins

Learn More

translatable

Installation

First add this repo URL to your composer:

1"repositories": [
2 {
3 "type": "github",
4 "url": "https://github.com/lara-zeus/translatable"
5 },
6]

and make sure your minimum stability is set to dev:

1"minimum-stability": "dev",

Then Install the plugin with Composer:

1composer require filament/spatie-laravel-translatable-plugin:"^3.2" -W

Adding the plugin to a panel

To add a plugin to a panel, you must include it in the configuration file using the plugin() method:

1use Filament\SpatieLaravelTranslatablePlugin;
2 
3public function panel(Panel $panel): Panel
4{
5 return $panel
6 // ...
7 ->plugin(SpatieLaravelTranslatablePlugin::make());
8}

Setting the default translatable locales

To set up the locales that can be used to translate content, you can pass an array of locales to the defaultLocales() plugin method:

1use Filament\SpatieLaravelTranslatablePlugin;
2 
3public function panel(Panel $panel): Panel
4{
5 return $panel
6 // ...
7 ->plugin(
8 SpatieLaravelTranslatablePlugin::make()
9 ->defaultLocales(['en', 'es']),
10 );
11}

Preparing your model class

You need to make your model translatable. You can read how to do this in Spatie's documentation.

Preparing your resource class

You must apply the Filament\Resources\Concerns\Translatable trait to your resource class:

1use Filament\Resources\Concerns\Translatable;
2use Filament\Resources\Resource;
3 
4class BlogPostResource extends Resource
5{
6 use Translatable;
7 
8 // ...
9}