public function translator(string $locale, string $domain, string $directory): ?TranslatorInterface
    {
        $class = GETTEXT_EXTENSION ? GettextTranslator::class : Translator::class;

        $previous = self::$translator;
        self::$translator = new $class($locale, $domain, $directory);

        if ($previous === null) {
            require __DIR__ . DIRECTORY_SEPARATOR . 'helpers.php';
        }

        $this->locale = $locale;

        return $previous;
    }