All plugin options can be chained on SpatieTranslatablePlugin::make() inside your Filament panel provider.
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 (defaults to []):
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}
Customizing locale labels
By default, locale labels in the locale switcher are resolved using PHP's locale_get_display_name() function, displayed in the active session locale (if set) or the current application locale.
You can customize how locale labels are generated using the getLocaleLabelUsing() method. The callback receives the $locale being labeled and the $displayLocale. Return null to fall back to the default locale_get_display_name() behavior:
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 ->getLocaleLabelUsing(fn (string $locale, string $displayLocale): ?string => match ($locale) {11 'en' => 'English',12 'es' => 'Español',13 default => null,14 }),15 );16}
Persisting the active locale in session
To remember the user's selected locale throughout their session across resource pages, you can enable the persist() method (defaults to false):
1use LaraZeus\SpatieTranslatable\SpatieTranslatablePlugin; 2 3public function panel(Panel $panel): Panel 4{ 5 return $panel 6 // ... 7 ->plugin( 8 SpatieTranslatablePlugin::make() 9 ->persist(),10 );11}
When enabled, the selected locale is stored in the session under spatie_translatable_active_locale and automatically restored when navigating between translatable pages.
Using the fallback locale
By default, when a translation is missing for the active locale, the field or table column is left empty (useFallbackLocale defaults to false). If you want forms, table columns, and translatable relationships to fall back to Spatie's configured fallback locale when a translation is missing, you can enable useFallbackLocale():
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 ->useFallbackLocale(),11 );12}
Validating all configured locales
By default (false), form validation only runs for the active locale and any other locales that the user has visited or modified (and on Edit pages, validation errors on unvisited locales are only enforced if that locale already has saved translations).
If you want to ensure that all required fields and validation rules across every configured locale are validated before a record is created or saved, you can enable the validateAllLocales() 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 ->validateAllLocales(),11 );12}
When enabled, on both CreateRecord and EditRecord pages (including translatable relationship fields), every locale returned by getTranslatableLocales() is validated before saving. If validation fails for any locale — even one the user hasn't switched to yet — the form automatically switches to the failing locale and displays its validation errors.
You can pass false to validateAllLocales(false) to explicitly disable this behavior.
Showing translatable field icons
To show a language icon next to the label of every form field bound to a translatable attribute, you can use the showIcon() method (defaults to false):
1use LaraZeus\SpatieTranslatable\SpatieTranslatablePlugin; 2 3public function panel(Panel $panel): Panel 4{ 5 return $panel 6 // ... 7 ->plugin( 8 SpatieTranslatablePlugin::make() 9 ->showIcon(),10 );11}
Fields with a hidden label, fields nested in a non-relationship repeater item, and custom rich editor block fields don't get an icon, since they are not stored as translatable attributes of the model.
You can customize the icon (string | BackedEnum | Htmlable), its color (string | array | null), and its position relative to the label (TranslatableFieldIconPosition::BeforeLabel or TranslatableFieldIconPosition::AfterLabel):
1use Filament\Support\Icons\Heroicon;2use LaraZeus\SpatieTranslatable\Enums\TranslatableFieldIconPosition;3use LaraZeus\SpatieTranslatable\SpatieTranslatablePlugin;4 5SpatieTranslatablePlugin::make()6 ->showIcon()7 ->icon(Heroicon::GlobeAlt)8 ->iconColor('gray')9 ->iconPosition(TranslatableFieldIconPosition::AfterLabel)
By default, the icon is Heroicon::Language, uses the primary color, and is shown before the label (TranslatableFieldIconPosition::BeforeLabel).
Our Sponsors
Zeus is an open-source project. Thanks to our sponsors for helping maintain these packages.