Search code examples
phpzend-framework2po-file

ZF2 2.2.4 issue with translator


I have an issue since i passed from ZF 2.2.0 to ZF 2.2.4 on my website, change language doesn't work.

This is my autoload/translator.global.php

Without change the source code, just switch to 2.2.0 it works, 2.2.4 is not.

<?php
return array(
'service_manager' => array(
    'factories' => array(
        'translator' => 'Zend\I18n\Translator\TranslatorServiceFactory',
    ),
),
'translator' => array(
    'locale' => 'en_US',
    'translation_file_patterns' => array(
        array(
            'type'     => 'gettext',
            'base_dir' => __DIR__ . '/../../language',
            'pattern'  => '%s.mo',
        ),
    ),
),

);


Solution

  • I solved the problem, since 2.2.1, you must use an alias

    <?php
    return array(
    'service_manager' => array(
        'allow_override' => 'true',
        'factories' => array(
            'translator' => 'Zend\I18n\Translator\TranslatorServiceFactory',
        ),
        'aliases' => array(
            'translator' => 'mvcTranslator',
        ),
    
    ),
    'translator' => array(
        'locale' => 'en_US',
        'translation_file_patterns' => array(
            array(
                'type'     => 'gettext',
                'base_dir' => __DIR__ . '/../../language',
                'pattern'  => '%s.mo',
            ),
        ),
    ),
    );