Assume you have installed foa/filter-input-bundle and foa/filter-input-bundle.
In your modify method you can get the service intl_translator_locator like
Setting Localized Messages For A Package
We can set localized messages for a package through the PackageLocator object
from the translator locator. We create a new Package with messages and place
it into the locator as a callable. The messages take the form of a message key and
and message string.
Setting The Default Locale
We can set the default locale for translations using the setLocale() method:
Getting A Localized Message
Now that the translator locator has messages and a default locale, we can get
an individual package translator. The package translator is suitable for
injection into another class, or for standalone use. You will neeed to
create a tanslator helper which can return the service.
You can get a translator for a non-default locale as well:
Replacing Message Tokens With Values
We often need to use dynamic values in translated messages. First, the
message string needs to have a token placeholder for the dynamic value:
Then, when we translate the message, we provide an array of tokens and
replacement values. These will be interpolated into the message string.
Usually, we need to use different messages when a value is singular or plural.
The BasicFormatter is not capable of presenting different messages based on
different token values. The IntlFormatteris capable, but the PHP
intl extension must be loaded to take advantage of
it, and we must specify the 'intl' formatter for the package in the catalog.
When using the IntlFormatter, we can build our message strings to present
singular or plural messages, as in the following example:
Note that you can use other tokens within a pluralized token string to build
more complex messages. For more information, see the following: