Page translatable

What I’m trying to do:
Make a custom Filament v3 Page translatable using spatie/laravel-translatable. I want the user to switch languages and edit localized values. What I did:
- My Setting model uses HasTranslations and stores JSON values correctly.
- My Page uses Translatable trait.
- Locale switcher appears via Actions\LocaleSwitcher::make().
- The form has inputs like TextInput::make('html_title'), RichEditor::make('footer_descript'), etc. The issue:
Switching the language via the locale switcher does not change the form input values.
Everything stays in the default locale. No errors in console or logs.
Expected: When switching to e.g. en, the form should load html_title and others in English. Code snippet:
class Settings extends Page implements HasForms
{
use InteractsWithForms, Translatable;

public ?array $data = [];

public function mount(): void
{
$this->form->fill([
'html_title' => Setting::get('html_title'),
'footer_descript' => Setting::get('footer_descript'),
]);
}

public function form(Form $form): Form
{
return $form
->statePath('data')
->schema([
TextInput::make('html_title')->label('HTML title'),
RichEditor::make('footer_descript')->label('Footer'),
]);
}

public function save(): void
{
foreach ($this->form->getState() as $key => $value) {
Setting::updateOrCreate(['key' => $key], ['value' => $value]);
}
}

protected function getHeaderActions(): array
{
return [ Actions\LocaleSwitcher::make() ];
}
}
class Settings extends Page implements HasForms
{
use InteractsWithForms, Translatable;

public ?array $data = [];

public function mount(): void
{
$this->form->fill([
'html_title' => Setting::get('html_title'),
'footer_descript' => Setting::get('footer_descript'),
]);
}

public function form(Form $form): Form
{
return $form
->statePath('data')
->schema([
TextInput::make('html_title')->label('HTML title'),
RichEditor::make('footer_descript')->label('Footer'),
]);
}

public function save(): void
{
foreach ($this->form->getState() as $key => $value) {
Setting::updateOrCreate(['key' => $key], ['value' => $value]);
}
}

protected function getHeaderActions(): array
{
return [ Actions\LocaleSwitcher::make() ];
}
}
Note:
This is a custom Page, not a Resource.
Model translation works fine outside Filament.
But in this Page form, switching language doesn’t affect input values. Any ideas what I’m missing?
Thanks!
3 Replies
rhysleesdev
rhysleesdev3mo ago
your ->label calls are not using ('')
TextInput::make('html_title')
->label('HTML title'),
RichEditor::make('footer_descript')
->label('Footer'),
TextInput::make('html_title')
->label('HTML title'),
RichEditor::make('footer_descript')
->label('Footer'),
should be: ```php TextInput::make('html_title') ->label(
('HTML title')), RichEditor::make('footer_descript') ->label(__('Footer')), ```
Takács Gábor
Takács GáborOP3mo ago
I want to translate the values of the inputs, not the labels…
Lara Zeus
Lara Zeus3mo ago
afaik filament translatable wont work with custom pages you best solution is to use a component like this: https://filamentphp.com/plugins/abdulmajeed-jamaan-translatable-tabs then you can remove the trait and lang switcher from the page

Did you find this page helpful?