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.
Namespace: Cake\I18n\Middleware
Property Summary
-
$locales protected
array
List of valid locales for the request
Method Summary
-
__construct() public
Constructor.
-
process() public
Set locale based on request headers.
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(ServerRequestInterface $request, RequestHandlerInterface $handler): Psr\Http\Message\ResponseInterface
Set locale based on request headers.
Processes an incoming server request in order to produce a response. If unable to produce the response itself, it may delegate to the provided request handler to do so.
Parameters
-
ServerRequestInterface
$request The request.
-
RequestHandlerInterface
$handler The request handler.
Returns
Psr\Http\Message\ResponseInterface