This component provides middleware for Mezzio
and PSR-7 applications to set the locale and the language for a translator based on the HTTP_ACCEPT_LANGUAGE Header.
This library requires
- PHP 8.3+.
- a translator
Run
composer require mimmi20/mezzio-setlocale-middleware<?php
return [
'middleware' => [
// ...
\Mimmi20\Mezzio\Middleware\SetLocaleMiddleware::class, // <-- Add this line
// ... <-- any middleware or request handler wich uses the translator
],
];If you need the Translator for the Routing, you have to add the Middleware in the Pipeline before the Routing.
$app->pipe(\Mimmi20\Mezzio\Middleware\SetLocaleMiddleware::class); // <-- Add this line
// Register the routing middleware in the middleware pipeline.
// This middleware registers the Mezzio\Router\RouteResult request attribute.
$app->pipe(RouteMiddleware::class);This package is licensed using the MIT License.
Please have a look at LICENSE.md.