We had internally many headaches due to multilanguage setup with livewire. But one day as i was trying to figure out way to made it work for multisites a discovered this piece in livewire docs. Which essentially solves all the problems with content loading from wrong db/language.
In short, you just need to match your url localization with update endpoint… For example ‘/es/livewire/update’… Then it just magically works!
Okay found out something based on JacobBlana answer.
SImply put this into your ThemeServiceProvider Boot method.
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
parent::boot();
// Get current language
// This my implementation. it return the WP lang if WPML or POlylnag isnt installed, otherwise we use the plugin API to retrieve the current lang code.
$curr_lang = Multilang::get_current_language(); /
// Define custom Livewire update route
Livewire::setUpdateRoute(function ($handle) use ($curr_lang) {
return Route::post("/{$curr_lang}/livewire/update", $handle);
});
// Rest of your code....
}