private function translate($key, $locale = null)
{
if (is_null($locale)) {
$locale = $this->translator->getLocale();
}
$translation = $this->translator->trans($key, [], '', $locale);
// @codeCoverageIgnoreStart
if (!is_string($translation)) {
throw new InvalidTranslationException("The translation key [{$key}] for locale [{$locale}] should return a string value.");
}
// @codeCoverageIgnoreEnd
return (string) $translation;
}