Page translatable
What I’m trying to do:
Make a custom Filament v3
- My
- My
- Locale switcher appears via
- The form has inputs like
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.
This is a custom
Model translation works fine outside Filament.
But in this
Thanks!
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:
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
your ->label calls are not using ('')
should be:
```php
TextInput::make('html_title')
->label(('HTML title')),
RichEditor::make('footer_descript')
->label(__('Footer')),
```
I want to translate the values of the inputs, not the labels…
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