interface TranslatableInterface

Interface for translatable data.

Hierarchy

Expanded class hierarchy of TranslatableInterface

All classes that implement TranslatableInterface

1 file declares its use of TranslatableInterface
EntityInterface.php in drupal/core/lib/Drupal/Core/Entity/EntityInterface.php
Definition of Drupal\Core\Entity\EntityInterface.

File

drupal/core/lib/Drupal/Core/TypedData/TranslatableInterface.php, line 13
Definition of Drupal\Core\TypedData\TranslatableInterface.

Namespace

Drupal\Core\TypedData
View source
interface TranslatableInterface {

  /**
   * Returns the default language.
   *
   * @return
   *   The language object.
   */
  public function language();

  /**
   * Returns the languages the data is translated to.
   *
   * @param bool $include_default
   *   Whether the default language should be included.
   *
   * @return
   *   An array of language objects, keyed by language codes.
   */
  public function getTranslationLanguages($include_default = TRUE);

  /**
   * Gets a translation of the data.
   *
   * The returned translation has to be implement the same typed data interfaces
   * as this typed data object, excluding the TranslatableInterface. E.g., if
   * this typed data object implements the ComplexDataInterface and
   * AccessibleInterface, the translation object has to implement both as well.
   *
   * @param $langcode
   *   The language code of the translation to get or LANGUAGE_DEFAULT to get
   *   the data in default language.
   * @param $strict
   *   (optional) If the data is complex, whether the translation should include
   *   only translatable properties. If set to FALSE, untranslatable properties
   *   are included (in default language) as well as translatable properties in
   *   the specified language. Defaults to TRUE.
   *
   * @return \Drupal\Core\TypedData\TypedDataInterface
   *   A typed data object for the translated data.
   */
  public function getTranslation($langcode, $strict = TRUE);

}

Members

Namesort descending Modifiers Type Description Overrides
TranslatableInterface::getTranslation public function Gets a translation of the data. 2
TranslatableInterface::getTranslationLanguages public function Returns the languages the data is translated to. 2
TranslatableInterface::language public function Returns the default language. 2