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
justhammin
justhamminOP7d ago
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.
Bruno Pereira
Bruno Pereira7d ago
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
justhammin
justhamminOP7d ago
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.
Bruno Pereira
Bruno Pereira7d ago
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
justhammin
justhamminOP7d ago
I've given up and simply took the language switcher off the list page. users can switch the language on the edit page.
Bruno Pereira
Bruno Pereira7d ago
Filament
Translatable Fields by Outerweb - Filament
Makes all Filament fields translatable with a translatable macro.
justhammin
justhamminOP6d ago
Okay, thanks for the tip.

Did you find this page helpful?