Classes that use annotations to provide information used to register also need to be able to be translated. Since annotations are not code or Twig templates, they need an alternate mechanism to define translatable text. For example:
/**
* Defines the file entity class.
*
* @EntityType(
* id = "file",
* label = @Translation("File"),
* ....
*/
class File {
}
This runs any text within the @Translation wrapper through the t() function.