* function ($translators) { * $adapter = new Gettext(); * $adapter->setUseIncludePath(true); * return $adapter; * } * * * You may need to override the Translator service factory to make this happen * more easily. That can be done by extending it: * * * use Zend\I18n\Translator\TranslatorServiceFactory; * // or Zend\Mvc\I18n\TranslatorServiceFactory * use Zend\ServiceManager\ServiceLocatorInterface; * * class MyTranslatorServiceFactory extends TranslatorServiceFactory * { * public function createService(ServiceLocatorInterface $services) * { * $translator = parent::createService($services); * $translator->getLoaderPluginManager()->setFactory(...); * return $translator; * } * } * * * You would then specify your custom factory in your service configuration. */ class LoaderPluginManager extends AbstractPluginManager { /** * Default set of loaders. * * @var array */ protected $invokableClasses = array( 'gettext' => 'Zend\I18n\Translator\Loader\Gettext', 'ini' => 'Zend\I18n\Translator\Loader\Ini', 'phparray' => 'Zend\I18n\Translator\Loader\PhpArray', ); /** * Validate the plugin. * * Checks that the filter loaded is an instance of * Loader\FileLoaderInterface or Loader\RemoteLoaderInterface. * * @param mixed $plugin * @return void * @throws Exception\RuntimeException if invalid */ public function validatePlugin($plugin) { if ($plugin instanceof Loader\FileLoaderInterface || $plugin instanceof Loader\RemoteLoaderInterface) { // we're okay return; } throw new Exception\RuntimeException(sprintf( 'Plugin of type %s is invalid; must implement %s\Loader\FileLoaderInterface or %s\Loader\RemoteLoaderInterface', (is_object($plugin) ? get_class($plugin) : gettype($plugin)), __NAMESPACE__ )); } }