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

This package is auto-updated.

Last update: 2024-06-12 13:02:16 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.

Continuous Integration Latest Stable Version License

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.