How to use Spatie Translatable in filament custom page?

I have a page that is not a resource because there will be one record. But I don't know how to make LocalSwitcher work. I have tried everything possible that came to my mind.
class PrivacyPolicy extends Page implements HasForms, HasActions
{
use InteractsWithForms;
use InteractsWithActions;

protected static ?string $navigationIcon = 'heroicon-o-document-text';

protected static string $view = 'filament.pages.privacy-policy';

public ?array $data = [];

public ?PrivacyPolicyModel $record = null;

public function mount(): void
{
//...
}

protected function getHeaderActions(): array
{
return [
LocaleSwitcher::make(),
];
}

public static function getTranslatableLocales(): array
{
return getSupportedLanguagesKeys();
}

public function form(Form $form): Form
{
return $form->schema([
//...
]);
}
}
class PrivacyPolicy extends Page implements HasForms, HasActions
{
use InteractsWithForms;
use InteractsWithActions;

protected static ?string $navigationIcon = 'heroicon-o-document-text';

protected static string $view = 'filament.pages.privacy-policy';

public ?array $data = [];

public ?PrivacyPolicyModel $record = null;

public function mount(): void
{
//...
}

protected function getHeaderActions(): array
{
return [
LocaleSwitcher::make(),
];
}

public static function getTranslatableLocales(): array
{
return getSupportedLanguagesKeys();
}

public function form(Form $form): Form
{
return $form->schema([
//...
]);
}
}
2 Replies
Lara Zeus
Lara Zeus2mo ago
dose the LocaleSwitcher appears normally but not working any errors?
slooffmaster
slooffmaster3w ago
Do you not get conflict between InteractsWithForms and Translatable. I am trying to achieve the same (making a custom page with an Edit form that is translatable) but this conflict is the first issue I cannot seem to fix. Have you come to a solution? In my case the LocaleSwitcher never shows up.

Did you find this page helpful?