fabiang / laminas-localize-helper
Laminas module for setting locale to all view helpers, validators and filters
v2.1.0
2024-02-12 12:05 UTC
Requires
- php: ^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0
- laminas/laminas-filter: ^2.0
- laminas/laminas-servicemanager: ^3.0
- laminas/laminas-validator: ^2.0
- laminas/laminas-view: ^2.0
- psr/container: ^1 || ^2
Requires (Dev)
- behat/behat: ^3.2.1
- laminas/laminas-coding-standard: ^2.5
- laminas/laminas-i18n: ^2.14
- laminas/laminas-mvc: ^3.0
- laminas/laminas-mvc-i18n: ^1.3
- laminas/laminas-router: ^3.5
- phpspec/prophecy-phpunit: ^2.0
- phpunit/phpunit: ^9.6.16 || ^10.0
- vimeo/psalm: ^5.21
This package is auto-updated.
Last update: 2024-11-12 13:51:41 UTC
README
Initializer that passes your configured locale to all view helpers, validators and filters, so you don't have to do this every time.
Installation
Run the following composer
command:
$ composer require fabiang/laminas-localize-helper
Configuration
Put the following into your plugin managers config (e.g. config/autoload/i18n.global.php
):
<?php return [ 'translator' => [ 'locale' => 'en_US', // this locale will be passed ], 'validators' => [ 'initializers' => [ \Fabiang\LocalizeHelper\LocaleInitializer::class, ] ], 'filters' => [ 'initializers' => [ \Fabiang\LocalizeHelper\LocaleInitializer::class, ] ], 'view_helpers' => [ 'initializers' => [ \Fabiang\LocalizeHelper\LocaleInitializer::class, ] ] ];
You can configure the initializer for each type of plugin by removing or adding it to the ValidatorManager/FilterManager/ViewHelperManager config above.
LICENSE
BSD-2-Clause. See the LICENSE.