Newer
Older
Dries Buytaert
committed
<?php
/**
* @file
* Contains \Drupal\Core\TypedData\TranslatableInterface.
Dries Buytaert
committed
*/
namespace Drupal\Core\TypedData;
/**
* Interface for translatable data.
*/
interface TranslatableInterface {
/**
* Returns the default language.
*
* @return \Drupal\Core\Language\Language
Dries Buytaert
committed
* The language object.
*/
public function language();
/**
* Returns the languages the data is translated to.
*
* @param bool $include_default
* (optional) Whether the default language should be included. Defaults to
* TRUE.
Dries Buytaert
committed
*
* @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::LANGCODE_DEFAULT
* to get the data in default language.
Dries Buytaert
committed
*
* @return \Drupal\Core\TypedData\TypedDataInterface
* A typed data object for the translated data.
*/
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
public function getTranslation($langcode);
/**
* Returns the translatable object referring to the original language.
*
* @return \Drupal\Core\TypedData\TranslatableInterface
* The translation object referring to the original language.
*/
public function getUntranslated();
/**
* Returns TRUE there is a translation for the given language code.
*
* @param string $langcode
* The language code identifiying the translation.
*
* @return bool
* TRUE if the translation exists, FALSE otherwise.
*/
public function hasTranslation($langcode);
/**
* Adds a new translation to the translatable object.
*
* @param string $langcode
* The language code identifying the translation.
* @param array $values
* (optional) An array of initial values to be assigned to the translatable
* fields. Defaults to none.
*
* @return \Drupal\Core\TypedData\TranslatableInterface
*/
public function addTranslation($langcode, array $values = array());
/**
* Removes the translation identified by the given language code.
*
* @param string $langcode
* The language code identifying the translation to be removed.
*/
public function removeTranslation($langcode);
Angie Byron
committed
/**
* Returns the translation support status.
*
* @return bool
* TRUE if the object has translation support enabled.
*/
public function isTranslatable();