Beispiel #1
0
 /**
  * Load catalogue data from source.
  *
  * @param string $locale
  * @return Catalogue
  */
 protected function loadCatalogue($locale)
 {
     $catalogue = new Catalogue($locale, $this->memory);
     if (array_key_exists($locale, $this->loadedLocales) && $this->config->cacheLocales()) {
         //Has been loaded
         return $catalogue;
     }
     $benchmark = $this->benchmark('load', $locale);
     try {
         //Loading catalogue data from source
         foreach ($this->source->loadLocale($locale) as $messageCatalogue) {
             $catalogue->mergeFrom($messageCatalogue);
         }
         //To remember that locale already loaded
         $this->loadedLocales[$locale] = $catalogue->getDomains();
         $this->memory->saveData(static::MEMORY, $this->loadedLocales);
         //Saving domains memory
         $catalogue->saveDomains();
     } finally {
         $this->benchmark($benchmark);
     }
     return $catalogue;
 }
Beispiel #2
0
 /**
  * Register string in active translator.
  *
  * @param string $domain
  * @param string $string
  */
 protected function register($domain, $string)
 {
     //Automatically registering
     $this->catalogue->set($domain, $string, $string);
     $this->logger()->debug("Found [{domain}]:'{string}'", compact('domain', 'string'));
 }