middleware
routes/web.php
Route::group(['prefix' => 'member', 'as' => 'member.', 'middleware' => ['auth', 'setLocale:zh-tw']], function () {
Route::get('/', App\Http\Livewire\MemberList::class);
});
app/Http/Middleware/SetLocale.php.php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
class SetLocale
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next, string $lang)
{
app()->setLocale($lang);
return $next($request);
}
}