src/Viserio/Bridge/Twig/Extension/TranslatorExtension.php
public function trans(string $id, $parameters = [], string $domain = 'messages', ?string $locale = null): string
    {
        if (\is_numeric($parameters)) {
            $parameters = ['count' => $parameters];
        }

        return $this->translationManager->getTranslator($locale)->trans($id, $parameters, $domain);
    }
public function trans(string $id, $parameters = [], string $domain = 'messages', ?string $locale = null): string
    {
        if (\is_numeric($parameters)) {
            $parameters = ['count' => $parameters];
        }

        return $this->translationManager->getTranslator($locale)->trans($id, $parameters, $domain);
    }
Translates the given message.

@param string      $id         The message id
@param mixed       $parameters An array of parameters for the message
@param string      $domain     The domain for the message or null to use the default
@param null|string $locale     The locale to change the translator language

@throws \InvalidArgumentException If the locale contains invalid characters
@throws \RuntimeException         If no translator found

@return string The translated string