Ejemplo n.º 1
0
 /**
  * Save new messages
  *
  * @author Krzysztof Bednarczyk
  */
 public function onKernelTerminate(PostResponseEvent $event)
 {
     if (!$event->isMasterRequest()) {
         return;
     }
     if (!method_exists($this->translator, 'getCollectedMessages')) {
         return;
     }
     $messages = $this->translator->getCollectedMessages();
     if (empty($messages)) {
         return;
     }
     $languagesToClear = [];
     foreach ($messages as $message) {
         if (!in_array((int) $message['state'], [DataCollectorTranslator::MESSAGE_MISSING, DataCollectorTranslator::MESSAGE_EQUALS_FALLBACK])) {
             continue;
         }
         if (!$this->manager->hasLocale($message['locale'])) {
             continue;
         }
         $language = $this->manager->getLanguage($message['locale']);
         $languagesToClear[$language->getId()] = $language;
         $this->manager->createTranslation($language, $message['id'], $message['domain']);
     }
     foreach ($languagesToClear as $language) {
         $this->manager->clearTranslationCache($language);
     }
 }
 /**
  * Warms up the cache.
  *
  * @param string $cacheDir The cache directory
  */
 public function warmUp($cacheDir)
 {
     $this->languageManager->generateLanguageFiles(true);
 }