ZF 2.3.0 BC break in MvcTranslator #5978

Martin-P opened this Issue Mar 15, 2014 · 14 comments


None yet

6 participants


Commit 9be9748 was done with the message Ensure TranslatorServiceFactory remains BC with < 2.3.0. Unfortunately it does the opposite and introduces a BC break. It requires the intl extension to be active, without the intl extension I now can not use the translator.

TranslatorServiceFactory, line 37:

// If ext/intl is not loaded, return a dummy translator
if (!extension_loaded('intl')) {
    return new MvcTranslator(new DummyTranslator());

When I comment out the check for intl everything works perfectly as it did before, so this check is definately the cause of the problem.

This is the config I use for my translations:

'service_manager' => array(
    'aliases' => array(
        'translator' => 'MvcTranslator',

'translator' => array(
    'locale' => 'nl_NL',
    'translation_file_patterns' => array(
            'type'     => 'phparray',
            'base_dir' => __DIR__ . '/../language',
            'pattern'  => 'lang.array.%s.php',

Suggested fix:
Do not require the intl extension for using the translator.


The intl extension is and has always been a requirement for ZendFramework if i'm not totally wrong.


Sorry, but you're wrong :) I use translations since ZF 2.2.4 at least and my hosting company does not have the intl extension enabled. Online I still use ZF 2.2.6 and messages get translated perfectly without the intl extension.

I just updated on my local computer from ZF 2.2.6 to ZF 2.3.0 and during testing I noticed my text not being translated anymore. As you can see in the commit I referenced in my post, the check for intl was added in ZF 2.3.0 (#5942).


AFAIK too "The intl extension is and has always been a requirement for ZendFramework" Quoting @macnibblet


@pauloelr Same as I said to @macnibblet: look at the commit :) Or better: test it yourself with ZF 2.2.6 without intl and you will see the translator can be used without the intl extension in ZF 2.2.6 and earlier versions. I understand you both assume the intl extension to be required, but my report is not based on assumptions, but on facts ;) Fact is: it worked perfectly in ZF 2.2.6 and does not work in ZF 2.3.0.

For those interested in a workaround:

  • Copy the file Zend\Mvc\Service\TranslatorServiceFactory to your own location, for instance Application\Mvc\Service\TranslatorServiceFactory
  • Comment out lines 38 - 40 in your newly created file Move lines 38 - 40 to just before the return statement in your newly created file
  • Add the following config which ensures your custom translator factory is used:
'service_manager' => array(
    'factories' => array(
        'MvcTranslator' => 'Application\Mvc\Service\TranslatorServiceFactory',
Zend Framework member

It's correct that, as long as a locale is configured, the Intl extension is not required by the translator.


@DASPRiD I have a locale configured under the translator config key, but still get a DummyTranslator. If I look at Zend\Mvc\Service\TranslatorServiceFactory I don't see the check for locale you refer to. If I look at the previous version of Zend\Mvc\Service\TranslatorServiceFactory I don't see that check either. Am I doing something wrong? My workaround (see above) by removing the check for intl extension fixes everything, so I think I can say the check for the intl extension is causing the problem.

Zend Framework member

Right, but removing the check does not solve the problem. The actual problem is the order of all the checks. If I see it correct, the extension check should come just before the last return statement.


I tested your suggestion and can confirm moving the check for intl fixes the problem.


@Martin-P Create a pull request for it then


Already working on it :)



@Ocramius Ocramius added bug I18n Mvc and removed I18n labels Apr 3, 2014
@Ocramius Ocramius added this to the 2.3.1 milestone Apr 3, 2014
@Ocramius Ocramius self-assigned this Apr 3, 2014
@Ocramius Ocramius added a commit that referenced this issue Apr 3, 2014
@Ocramius Ocramius Merge branch 'hotfix/#5979-#5978-translator-service-factory-without-i…
…ntl' into develop

Close #5979 #5978
Forward Port #5979 #5978

@Ocramius based on #5979 this issue can be closed now ?

Zend Framework member

@samsonasik thanks for the reminder :-)

@Ocramius Ocramius closed this Apr 5, 2014

@Ocramius you're welcome ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment