public function init()
 {
     $this->app->configs->setDefaultConfig($this->id, new TranslatorConfig(), $this);
     $this->translator = $translator = new Translator();
     /** @var TranslatorConfig $config */
     $this->moduleConfig = $config = $this->app->configs->getConfig($this->id);
     if (!$this->app->getConfig()->developmentMode) {
         $c = new Filesystem();
         $o = new FilesystemOptions();
         $o->setCacheDir($this->app->cacheStorage->createStorage($this->id));
         $c->setOptions($o);
         $c->addPlugin(new Serializer());
         $translator->setCache($c);
     }
     $translator->setLocale($config->defaultLanguage);
     $folder = $this->app->parseUri($config->translationsDirectory);
     foreach ($config->contexts as $context => $file) {
         if (is_int($context)) {
             $context = $file;
             $file .= '.mo';
         }
         $translator->addTranslationFilePattern('gettext', $folder, '%s/' . $file, $context);
     }
     $this->translator = $translator;
 }
 /**
  * Adds the caching mechanism to the dependency injection container with key 'descriptor.cache'.
  *
  * @param Application $app
  *
  * @return void
  */
 protected function addCache(Application $app)
 {
     $app['descriptor.cache'] = $app->share(function () {
         $cache = new Filesystem();
         $cache->setOptions(array('namespace' => 'phpdoc-cache', 'cache_dir' => sys_get_temp_dir()));
         $plugin = new SerializerPlugin();
         if (extension_loaded('igbinary')) {
             $options = new PluginOptions();
             $options->setSerializer('igbinary');
             $plugin->setOptions($options);
         }
         $cache->addPlugin($plugin);
         return $cache;
     });
 }
 /**
  * Adds the caching mechanism to the dependency injection container with key 'descriptor.cache'.
  *
  * @param Application $app
  *
  * @return void
  */
 protected function addCache(Application $app)
 {
     $app['descriptor.cache'] = $app->share(function () {
         $cache = new Filesystem();
         $cache->setOptions(array('namespace' => 'phpdoc-cache', 'cache_dir' => sys_get_temp_dir()));
         $cache->addPlugin(new SerializerPlugin());
         return $cache;
     });
 }