Example #1
0
 /**
  * @param TranslatorInterface $translator
  */
 public function perform(TranslatorInterface $translator)
 {
     if (!empty($this->option('lang'))) {
         $translator->setLocale($this->option('lang'));
     }
     $this->writeln("<info>{$translator->trans("Welcome to Spiral Framework")}</info>");
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function modify($source, $namespace, $name)
 {
     //Translator options must automatically route this view name to specific domain
     $domain = $this->translator->resolveDomain($this->options['prefix'] . str_replace(['/', '\\'], '-', $namespace . '-' . $name));
     return preg_replace_callback($this->options['pattern'], function ($matches) use($domain) {
         return $this->translator->trans($matches[1], [], $domain);
     }, $source);
 }
Example #3
0
 /**
  * @param array $matches
  * @return string
  */
 protected function replace($matches)
 {
     return $this->translator->translate($this->bundle, $matches[1]);
 }