Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

salvador98's avatar

Is it a good idea to use the HTTP Accept-Language header to set the locale of the user?

i use vuejs with laravel . i want set user local . i use this way? is it good?

axios.interceptors.request.use(
    function (config) {
        config.headers['Accept-Language']='en' or 'fr'
          return config;
    },
    function (error) {
        return Promise.reject(error);
    }
);

in middleware

  public function handle($request, Closure $next)
    {
        if ($request->header('Accept-Language'))
            \App::setLocale($request->header('Accept-Language'));
        return $next($request);
    }
    ```
0 likes
1 reply

Please or to participate in this conversation.