TranslatorListener::getSubscribedEvents()

static array getSubscribedEvents() Returns an array of event names this subscriber wants to listen to. The array keys are event names and the value can be: The method name to call (priority defaults to 0) An array composed of the method name to call and the priority An array of arrays composed of the method names to call and respective priorities, or 0 if unset For instance: array('eventName' => 'methodName') array('eventName' => array('methodName', $priority)) a

TranslatorListener

class TranslatorListener implements EventSubscriberInterface Synchronizes the locale between the request and the translator. Methods __construct(TranslatorInterface $translator, RequestStack $requestStack) onKernelRequest(GetResponseEvent $event) onKernelFinishRequest(FinishRequestEvent $event) static array getSubscribedEvents() Returns an array of event names this subscriber wants to listen to. Details __construct(TranslatorInterface $t

TranslatorInterface::cssToXPath()

string cssToXPath(string $cssExpr, string $prefix = 'descendant-or-self::') Translates a CSS selector to an XPath expression. Parameters string $cssExpr string $prefix Return Value string

TranslatorInterface::getLocale()

string getLocale() Returns the current locale. Return Value string The locale

TranslatorInterface::setLocale()

setLocale(string $locale) Sets the current locale. Parameters string $locale The locale Exceptions InvalidArgumentException If the locale contains invalid characters

TranslatorInterface::transChoice()

string transChoice(string $id, int $number, array $parameters = array(), string|null $domain = null, string|null $locale = null) Translates the given choice message by choosing a translation according to a number. Parameters string $id The message id (may also be an object that can be cast to string) int $number The number to use to find the indice of the message array $parameters An array of parameters for the message string|null $domain The domain for the message or null to u

TranslatorInterface::trans()

string trans(string $id, array $parameters = array(), string|null $domain = null, string|null $locale = null) Translates the given message. Parameters string $id The message id (may also be an object that can be cast to string) array $parameters An array of parameters for the message string|null $domain The domain for the message or null to use the default string|null $locale The locale or null to use the default Return Value string The translated string Exceptions InvalidArgum

TranslatorInterface::selectorToXPath()

string selectorToXPath(SelectorNode $selector, string $prefix = 'descendant-or-self::') Translates a parsed selector node to an XPath expression. Parameters SelectorNode $selector string $prefix Return Value string

TranslatorInterface

interface TranslatorInterface TranslatorInterface. Methods string trans(string $id, array $parameters = array(), string|null $domain = null, string|null $locale = null) Translates the given message. string transChoice(string $id, int $number, array $parameters = array(), string|null $domain = null, string|null $locale = null) Translates the given choice message by choosing a translation according to a number. setLocale(string $locale) Sets the current locale. string getLoc

TranslatorHelper::trans()

trans($id, array $parameters = array(), $domain = 'messages', $locale = null) Parameters $id array $parameters $domain $locale See also TranslatorInterface::trans()