mimmi20 / mezzio-setlocale-middleware
Provides a Middleware to set the Locale and the language to a translator
Installs: 141 666
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 1
Open Issues: 0
Requires
- php: ~8.3.0 || ~8.4.0 || ~8.5.0
- ext-intl: *
- laminas/laminas-i18n: ^2.30.0
- laminas/laminas-translator: ^1.1.0
- psr/container: ^1.1.2 || ^2.0.2
- psr/http-message: ^1.0.1 || ^2.0
- psr/http-server-handler: ^1.0.2
- psr/http-server-middleware: ^1.0.2
Requires (Dev)
- ext-ctype: *
- ext-dom: *
- ext-simplexml: *
- ext-tokenizer: *
- ext-xml: *
- ext-xmlwriter: *
- infection/infection: ^0.30.3
- mimmi20/coding-standard: ^6.1.7
- nikic/php-parser: ^5.6.0
- phpstan/extension-installer: ^1.4.3
- phpstan/phpstan: ^2.1.21
- phpstan/phpstan-deprecation-rules: ^2.0.3
- phpunit/phpunit: ^12.2.8
- rector/rector: ^2.1.2
- rector/type-perfect: ^2.1.0
- shipmonk/composer-dependency-analyser: ^1.8.3
- symfony/process: ^7.3.0
- symplify/phpstan-rules: ^14.6.11
- tomasvotruba/cognitive-complexity: ^1.0.0
- tomasvotruba/type-coverage: ^2.0.2
- tomasvotruba/unused-public: ^2.0.1
This package is auto-updated.
Last update: 2025-08-07 02:27:08 UTC
README
Code Status
Introduction
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.
Requirements
This library requires
- PHP 8.3+.
- a translator
Installation
Run
composer require mimmi20/mezzio-setlocale-middleware
Add the Middleware to the pipeline
<?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);
License
This package is licensed using the MIT License.
Please have a look at LICENSE.md
.