defaultLocale = $defaultLocale; $this->messages = $messages; } /** @inheritDoc */ public function translate($key, array $args = [], Locale $locale = null) { $locales = [ $locale, $this->defaultLocale, Locale::parse('en'), ]; foreach ($locales as $locale) { if (!$locale) { continue; } $message = $this->messages->get($key, $locale); if ($message) { return $message->format($args); } } return $key; } }