Class LocaleSelectorMiddleware

Sets the runtime default locale for the request based on the Accept-Language header. The default will only be set if it matches the list of passed valid locales.

Properties summary

  • $locales protected
    array

    List of valid locales for the request

Method Summary

Method Detail

__construct() public

__construct(array $locales)

Constructor.

Parameters

array $locales optional

A list of accepted locales, or ['*'] to accept any locale header value.

process() public

process(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Server\RequestHandlerInterface $handler)

Set locale based on request headers.

Parameters

\Psr\Http\Message\ServerRequestInterface $request

The request.

\Psr\Http\Server\RequestHandlerInterface $handler

The request handler.

Returns

\Psr\Http\Message\ResponseInterface

A response.

Property Detail

$locales protected

List of valid locales for the request

Type

array

© 2005–present The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/4.1/class-Cake.I18n.Middleware.LocaleSelectorMiddleware.html