What is the difference between t() and @Translation()? When writing a (translatable) plugin in Drupal 8, you have to use Drupal\Core\Annotation\Translation;, and then wrap your value in @Translation("value"), however when implementing the FormInterface, you can use t() freely as you would in Drupal 7.

I found Annotation-based plugins on Drupal.org, but it just mentions the fact that you should use it, and the Doctrine reference doesn't seem to include @Translation

I assume it is because the plugin system is part of doctrine, and not part of core, whereas t() is  -is this the correct assumption?

Basically, what is the difference between @Translation(); and t() - is it just because plugins are Doctrine based?
In short, @Translation() is a string used in annotations, meta data written in PHP comments and pertinent to a Drupal 8 class.

For example, this is the annotation for the PathItem entity field class.

/**
 * Defines the 'path_field' entity field item.
 *
 * @DataType(
 *   id = "path_field",
 *   label = @Translation("Path field item"),
 *   description = @Translation("An entity field containing a path alias and related data."),
 *   list_class = "\Drupal\Core\Entity\Field\Field"
 * )
 */


When Drupal loads the class annotations from a file, and it finds @Translation("Content") in the annotation, it creates an instance of the Translation class whose constructor receives the "Content" string; the instance is then used to get the value of t("Content").

As for the differences, they are the following ones:


@Translation() is a string used in class annotations: plain text that follows a specific format and it is written in PHP comments before the class that is being annotated. You cannot use it in code similar to the following one, except in the case a module defines a Translation() function. In that case, the @ before it would be understood from PHP as the error control operator.

$form['salary'] = array(
  '#type' =&gt; 'textfield',
  '#title' =&gt; @Translation('Salary'),
  '#size' =&gt; 10,
  '#maxlength' =&gt; 10,
  '#description' =&gt; @Translation('Please enter a valid number'),
);

t() is a Drupal function. It cannot be used inside class annotations like the following one, since it doesn't follow the syntax annotations follow. If it were used in an annotation as in the following, it would not cause Drupal to call t() and use its return value. 

/**
 * Defines the 'path_field' entity field item.
 *
 * @DataType(
 *   id = "path_field",
 *   label = t("Path field item"),
 *   description = t("An entity field containing a path alias and related data."),
 *   list_class = "\Drupal\Core\Entity\Field\Field"
 * )
 */