Classes with annotations serve to define entity types, plugins and so on. Annotations are not executable code as-is, so we need a specific syntax to mark strings to be translated. The @Translation()
wrapper serves this purpose. It will run the text through t()
when the annotation is evaluated.
Example:
/**
* Defines the file entity class.
*
* @EntityType(
* id = "file",
* label = @Translation("File"),
* ....
*/
class File {
}
Example with context:
/**
* Defines the file entity class.
*
* @EntityType(
* id = "file",
* label = @Translation("Text in context", context="Name of context"),
* ....
*/
class File {
}