Set application wide translation cache for console jobs

Hi

I have a few console jobs running via laminas-cli which uses the translation as provided by laminas-mvc-i18n and laminas-i18n. Translation works with only configuration being present right now.

However, I haven’t figured out how to configure a system wide translation cache for all jobs started that way.

Regards
Fabian

Resolved by adding the configuration of the cache directly to the translator.

    'translator' => [
        'translation_file_patterns' => [
            [
                'type'     => 'gettext',
                'base_dir' => __DIR__ . '/../language',
                'pattern'  => '%s.mo',
            ],
        ],
        'cache' => [
            'adapter' => [
                'name'     => Filesystem::class,
                'options'  => [
                    'cache_dir' => 'data/cache/translation',
                    'ttl' => 31536000,
                ]
            ],
            'plugins' => [
                Serializer::class,
                'exception_handler' => [
                    'throw_exceptions' => false
                ],
            ],
        ]
    ],
1 Like