Example #1
0
 /**
  * Write translations to storage.
  */
 public function writeToStorage()
 {
     try {
         $this->storage->write($this->translations);
     } catch (BadRequest400Exception $e) {
         // Empty bulk commit exception.
     }
 }
Example #2
0
 /**
  * Exports translations from ES to files.
  *
  * @param array $domains To export.
  */
 public function export($domains = [])
 {
     foreach ($this->readStorage($domains) as $file => $translations) {
         if (!file_exists($file)) {
             $this->getFilesystem()->touch($file);
         }
         list($domain, $locale, $extension) = explode('.', $file);
         if ($this->loadersContainer && $this->loadersContainer->has($extension)) {
             $messageCatalogue = $this->loadersContainer->get($extension)->load($file, $locale, $domain);
             $translations = array_merge($messageCatalogue->all($domain), $translations);
         }
         $this->exporter->export($file, $translations);
     }
     if (!empty($this->refresh)) {
         $this->storage->write($this->refresh);
         $this->refresh = [];
     }
 }