How to persist localeSwitcher
I've added Spatie Translatable and the Actions\LocaleSwitcher to my list and edit pages. My default langauge is en. I have one other es language. When I switch to es, then hit edit on the list page, it loads the page in en. Is there a way to make the localeSwitcher selection persist across page loads?
7 Replies
I've found a way to add ?lang=es to the edit url, but I don't know how to get livewire to switch it's activeLocale to es.
the plugin only changes the language in the specific page you use the dropdown. If you need to persist the language you can create a middleware to set the language on every request based on the dropdown choice
The problem is livewire doesn't pick up that value. I'm hoping to create a custom switcher that sets the selected value to the session and then set the activeLocale on the edit and list page to the session value if I can find a way to override them.
thats because the plugin changes on the livewire component, once you change to the editUser page, which is another livewire component it has its own locale value
I've given up and simply took the language switcher off the list page. users can switch the language on the edit page.
I normally use this one https://filamentphp.com/plugins/outerweb-translatable-fields
Filament
Translatable Fields by Outerweb - Filament
Makes all Filament fields translatable with a translatable macro.
Okay, thanks for the tip.