/** * @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>"); }
/** * {@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); }
/** * @param array $matches * @return string */ protected function replace($matches) { return $this->translator->translate($this->bundle, $matches[1]); }