Featured Post

Localizing application in Zend Framework 2

Today I would like to focus on translating application in Zend Framework 2. Overview By default, tutorial application has included Zend\I18n\Translator\Translator configuration in /module/Application/config/module.config.php as follow: PHP // ... 'translator' =>...

Read More

Issues with translation related to Zend Framework 2.2 upgrade

Posted by evolic | Posted in No category | Posted on 04-08-2013

Tags: , , , ,


Hi there,

This time I will take a look at recent issue I met during the upgrade of Zend Framework 2.

There is a note at the website http://framework.zend.com/manual/2.2/en/modules/zend.validator.html as follow:

A new service has also been registered with the MVC, MvcTranslator, which will return this specialized, bridge instance.

Most users should see no issues, as Zend\Validator\ValidatorPluginManager has been modified to use the MvcTranslator service internally, which is how most developers were getting the translator instance into validators in the first place. You will only need to change code if you were manually injecting the instance previously.


It seems I am not listed in the group of most users, because after updating Zend Framework 2 to version 2.2.x using Composer I noticed that my application won’t translate to specified language.

MvcTranslator was introduced in Zend Framework 2.2 as internal class used to translate text in the MVC architecture. As mentioned before users shouldn’t noticed it’s occurrence but in my case it was not so easy.

It took me a while to investigate the problem and I eventually made it.


It is quite simple, but it took me over an hour to find it.

We need to add following code to module.config.php of the Application module:

In case you get following Fatal error:
An alias by the name “translator” or “translator” already exists
I put here solution for that issue (it worked in my case).

In the file module.config.php I had following code:

All you need is to remove or comment out the line with translator key.

If you want to use MvcTranslator with form validators, following code could help you:

And that is all for today. I hope this post will be useful to you.

Write a comment