コード例 #1
0
ファイル: WelcomeCommand.php プロジェクト: spiral/application
 /**
  * @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>");
 }
コード例 #2
0
ファイル: TranslateModifier.php プロジェクト: vvval/spiral
 /**
  * {@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);
 }
コード例 #3
0
 /**
  * @param array $matches
  * @return string
  */
 protected function replace($matches)
 {
     return $this->translator->translate($this->bundle, $matches[1]);
 }