コード例 #1
0
ファイル: Translator.php プロジェクト: vvval/spiral
 /**
  * Get message from specific locale, add it into fallback locale cache (to be later exported) if
  * enabled (see TranslatorConfig) and no translations found.
  *
  * @param string $domain
  * @param string $string
  * @param string $locale
  * @return string
  */
 protected function get($domain, $string, $locale)
 {
     if ($this->getCatalogue($locale)->has($domain, $string)) {
         return $this->getCatalogue($locale)->get($domain, $string);
     } elseif ($this->fallbackCatalogue->has($domain, $string)) {
         return $this->fallbackCatalogue->get($domain, $string);
     }
     if ($this->config->autoRegistration()) {
         /*
          * Automatic message registration.
          */
         $this->fallbackCatalogue->set($domain, $string, $string);
         //Into memory
         $this->fallbackCatalogue->saveDomains();
     }
     //Unable to find translation
     return $string;
 }
コード例 #2
0
ファイル: Indexer.php プロジェクト: vvval/spiral
 /**
  * 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'));
 }