spatie-translatable

Installation

Installation

Install the plugin with Composer:

1composer require lara-zeus/spatie-translatable

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 LaraZeus\SpatieTranslatable\SpatieTranslatablePlugin;
2 
3public function panel(Panel $panel): Panel
4{
5 return $panel
6 // ...
7 ->plugin(SpatieTranslatablePlugin::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 LaraZeus\SpatieTranslatable\SpatieTranslatablePlugin;
2 
3public function panel(Panel $panel): Panel
4{
5 return $panel
6 // ...
7 ->plugin(
8 SpatieTranslatablePlugin::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 LaraZeus\SpatieTranslatable\Resources\Concerns\Translatable trait to your resource class:

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

Zeus is an open-source project. Thanks to my sponsors for helping me maintain this project.