class PluralTranslation extends AnnotationBase (View source)

Defines an annotation object for strings that require plural forms.

Note that the return values for both 'singular' and 'plural' keys needs to be passed to \Drupal\Core\StringTranslation\TranslationInterface::formatPlural().

For example, the annotation can look like this:

Properties

string $id

The annotated class ID.

from  AnnotationBase
protected string $class

The class used for this annotated class.

from  AnnotationBase
protected string $provider

The provider of the annotated class.

from  AnnotationBase
protected string $singular

The string for the singular case.

protected string $plural

The string for the plural case.

protected string $context

The context the source strings belong to.

Methods

string
getProvider()

Gets the name of the provider of the annotated class.

setProvider(string $provider)

Sets the name of the provider of the annotated class.

string
getId()

Gets the unique ID for this annotated class.

string
getClass()

Gets the class of the annotated class.

setClass(string $class)

Sets the class of the annotated class.

__construct(array $values)

Constructs a new class instance.

get()

Gets the value of an annotation.

Details

string getProvider()

Gets the name of the provider of the annotated class.

Return Value

string

setProvider(string $provider)

Sets the name of the provider of the annotated class.

Parameters

string $provider

The provider of the annotated class.

string getId()

Gets the unique ID for this annotated class.

Return Value

string

string getClass()

Gets the class of the annotated class.

Return Value

string

setClass(string $class)

Sets the class of the annotated class.

Parameters

string $class

The class of the annotated class.

__construct(array $values)

Constructs a new class instance.

Parameters

array $values

An associative array with the following keys:

  • singular: The string for the singular case.
  • plural: The string for the plural case.
  • context: The context the source strings belong to.

Exceptions

InvalidArgumentException

get()

Gets the value of an annotation.