Skip to content

Translate annotations

BowlOfSoup edited this page Sep 16, 2020 · 2 revisions

Specify your domain (the .xliff file)

By default, the translation must be in a Resources/translations/messages.en.xliff. You can specify a custom domain (xliff file)

/**
 * @Bos\Normalize(group={"somegroup"}, name="automobile")
 * @Bos\Translate(group={"translation"}, domain="some_domain")
 */
private $propertyToBeNormalized

This tries to find the translation in Resources/translations/some_domain.en.xliff.

Specify your locale (language)

You can specify your locale, if you did not set that globally in Symfony.

/**
 * @Bos\Normalize(group={"somegroup"}, name="automobile")
 * @Bos\Translate(group={"translation"}, domain="some_domain", locale="nl")
 */
private $propertyToBeNormalized

This will search for the translation in Resources/translations/some_domain.nl.xliff, notice the nl in the file name (Dutch language).

Clone this wiki locally