translator = $translator; $this->logger = $logger; } /** * Render source text * * @param [] $source * @param [] $arguments * @return string * @throws \Exception * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function render(array $source, array $arguments) { $text = end($source); /* If phrase contains escaped quotes then use translation for phrase with non-escaped quote */ $text = str_replace('\"', '"', $text); $text = str_replace("\\'", "'", $text); try { $data = $this->translator->getData(); } catch (\Exception $e) { $this->logger->critical($e->getMessage()); throw $e; } return array_key_exists($text, $data) ? $data[$text] : end($source); } }