简体   繁体   中英

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',
        ),
    ),
),

);

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',
        ),
    ),
),
);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM