private function getByExtensionName($extensionName)
    {
        if ($extensionName === '') {
            throw new \InvalidArgumentException('The parameter $extensionName must not be empty.', 1331489578);
        }

        if (!ExtensionManagementUtility::isLoaded($extensionName)) {
            throw new \BadMethodCallException(
                'The extension with the name "' . $extensionName . '" is not loaded.',
                1331489598
            );
        }

        if (!isset($this->translators[$extensionName])) {
            $localizedLabels = $this->getLocalizedLabelsFromFile($extensionName);
            // Overrides the localized labels with labels from TypoScript only
            // in the front end.

            if (($this->getFrontEndController() !== null)
                && isset($localizedLabels[$this->languageKey])
                && is_array($localizedLabels[$this->languageKey])
            ) {
                $labelsFromTyposcript = $this->getLocalizedLabelsFromTypoScript($extensionName);

                foreach ($labelsFromTyposcript as $labelKey => $labelFromTyposcript) {
                    $localizedLabels[$this->languageKey][$labelKey][0]['target'] = $labelFromTyposcript;
                }
            }

            /** @var \Tx_Oelib_Translator $translator */
            $translator = GeneralUtility::makeInstance(
                \Tx_Oelib_Translator::class,
                $this->languageKey,
                $this->alternativeLanguageKey,
                $localizedLabels
            );
            $this->translators[$extensionName] = $translator;
        }

        return $this->translators[$extensionName];
    }