/**
  * exposeTranslationAction action.
  */
 public function exposeTranslationAction(Request $request, $domain_name, $_locale, $_format)
 {
     $cache = new ConfigCache($this->cacheDir . '/' . $domain_name . '.' . $_locale . '.' . $_format, $this->debug);
     if (!$cache->isFresh()) {
         $locales = $this->translationFinder->createLocalesArray(array($this->localeFallback, $_locale));
         $files = array();
         foreach ($locales as $locale) {
             foreach ($this->translationFinder->getResources($domain_name, $locale) as $file) {
                 $files[] = $file;
             }
         }
         $resources = array();
         $catalogues = array();
         foreach ($files as $file) {
             $extension = pathinfo($file->getFilename(), \PATHINFO_EXTENSION);
             if (isset($this->loaders[$extension])) {
                 $resources[] = new FileResource($file->getPath());
                 $catalogues[] = $this->loaders[$extension]->load($file, $_locale, $domain_name);
             }
         }
         $messages = array();
         foreach ($catalogues as $catalogue) {
             $messages = array_replace_recursive($messages, $catalogue->all());
         }
         $content = $this->engine->render('BazingaExposeTranslationBundle::exposeTranslation.' . $_format . '.twig', array('messages' => $messages, 'locale' => $_locale, 'defaultDomains' => $this->defaultDomains));
         $cache->write($content, $resources);
     }
     $content = file_get_contents((string) $cache);
     $response = new Response($content);
     $response->prepare($request);
     $response->setPublic();
     $response->setETag(md5($response->getContent()));
     $response->isNotModified($request);
     return $response;
 }
 /**
  * Get all translation messages
  *
  * @return array
  */
 protected function getTranslationMessages()
 {
     $messages = array();
     foreach ($this->finder->getAllResources() as $file) {
         $fileName = explode('.', $file->getFilename());
         $extension = end($fileName);
         $locale = prev($fileName);
         $domain = array();
         while (prev($fileName)) {
             $domain[] = current($fileName);
         }
         $domain = implode('.', $domain);
         if (isset($this->loaders[$extension])) {
             $catalogue = $this->loaders[$extension]->load($file, $locale, $domain);
             if (isset($messages[$locale])) {
                 $messages[$locale] = array_replace_recursive($messages[$locale], $catalogue->all());
             } else {
                 $messages[$locale] = $catalogue->all();
             }
         }
     }
     return $messages;
 }