Laravel change locale not working

后端 未结 5 1774
温柔的废话
温柔的废话 2020-12-09 10:00

I am using a dropdown lists for the languages, consisting of english and dutch.

5条回答
  •  不知归路
    2020-12-09 10:09

    setLocale will only change the language for the rest of the request from that point on.

    So to persist it, you could look into setting the selected language in a session (https://laravel.com/docs/session). Then you can create a middeware (https://laravel.com/docs/middleware) where you can check if a language is set in the session and then apply it for the request :)

提交回复
热议问题