Zend Framework 2 offered functionality for integrating internationalization capabilities provided by zend-i18n into MVC applications. This support includes:
- registration of an
MvcTranslatorservice by default.
DummyTranslator, for use when
ext/intlis unavailable, or configuration dictates that translations are disabled.
MvcTranslator, which implements both
Zend\Validator\TranslatorInterface, which decorates a
TranslatorAwareTreeRouteStack, for enabling internationalized routing segments.
Since this functionality is entirely opt-in, we have decided that for version 3 of zend-mvc, we will offer it as a standalone package, to install when required for your applications.
Additionally, because it bridges multiple
and provides i18n-capable routing, it can be useful with non-zend-mvc
applications such as zend-expressive.
Basic installation is via composer:
$ composer require zendframework/zend-mvc-i18n
Assuming you are using the component installer, doing so will automatically enable the component in your application.
If you are not using the component installer, you will need to add the entry:
to your list of active modules. This is usually provided in one of the following files:
config/application.config.php(vanilla ZF skeleton application)
Manually enabling with zend-expressive
If you are not using the component-installer with zend-expressive, you will need to add the entry:
config/config.phpclass, assuming you are already using zend-config-aggregator.
If you are not, add a new global
config/autoload/file with the following contents:
```php <?php use Zend\Mvc\I18n\ConfigProvider;
$provider = new ConfigProvider(); return $provider(); ```
In order to separate the i18n integration features from zend-mvc, we made a few minor changes. While most of these are under-the-hood implementation details, please read the migration guide to verify your application will continue to work.
Found a mistake or want to contribute to the documentation? Edit this page on GitHub!