Arcanedev\Localization\Utilities\RouteTranslator::translate PHP Method

translate() private method

Get the translation for a given key.
private translate ( string $key, string $locale = null ) : string
$key string
$locale string
return string
    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;
    }