diff --git a/core/lib/Drupal/Core/Entity/Annotation/ConfigEntityType.php b/core/lib/Drupal/Core/Entity/Annotation/ConfigEntityType.php index 795ab27..7126eff 100644 --- a/core/lib/Drupal/Core/Entity/Annotation/ConfigEntityType.php +++ b/core/lib/Drupal/Core/Entity/Annotation/ConfigEntityType.php @@ -28,7 +28,7 @@ class ConfigEntityType extends EntityType { * {@inheritdoc} */ public function get() { - $this->definition['group_label'] = \Drupal::translation()->translate('Configuration', array(), array('context' => 'Entity type group')); + $this->definition['group_label'] = $this->t('Configuration', array(), array('context' => 'Entity type group')); return parent::get(); } diff --git a/core/lib/Drupal/Core/Entity/Annotation/ContentEntityType.php b/core/lib/Drupal/Core/Entity/Annotation/ContentEntityType.php index 6356fc1..ddf05c9 100644 --- a/core/lib/Drupal/Core/Entity/Annotation/ContentEntityType.php +++ b/core/lib/Drupal/Core/Entity/Annotation/ContentEntityType.php @@ -28,7 +28,7 @@ class ContentEntityType extends EntityType { * {@inheritdoc} */ public function get() { - $this->definition['group_label'] = \Drupal::translation()->translate('Content', array(), array('context' => 'Entity type group')); + $this->definition['group_label'] = $this->t('Content', array(), array('context' => 'Entity type group')); return parent::get(); } diff --git a/core/lib/Drupal/Core/Entity/Annotation/EntityType.php b/core/lib/Drupal/Core/Entity/Annotation/EntityType.php index d72d759..fa5d4b3 100644 --- a/core/lib/Drupal/Core/Entity/Annotation/EntityType.php +++ b/core/lib/Drupal/Core/Entity/Annotation/EntityType.php @@ -41,4 +41,13 @@ public function get() { return new $class($values); } + /** + * Translates a string to the current language or to a given language. + * + * See the t() documentation for details. + */ + protected function t($string, array $args = array(), array $options = array()) { + return \Drupal::translation()->translate($string, $args, $options); + } + } diff --git a/core/lib/Drupal/Core/Entity/EntityManager.php b/core/lib/Drupal/Core/Entity/EntityManager.php index 0b64c28..242e01e 100644 --- a/core/lib/Drupal/Core/Entity/EntityManager.php +++ b/core/lib/Drupal/Core/Entity/EntityManager.php @@ -487,7 +487,7 @@ public function getEntityTypeLabels($group = FALSE) { } // Make sure that the 'Content' group is situated at the top. - $content = \Drupal::translation()->translate('Content', array(), array('context' => 'Entity type group')); + $content = $this->t('Content', array(), array('context' => 'Entity type group')); $options = array($content => $options[$content]) + $options; } @@ -527,4 +527,13 @@ public function getTranslationFromContext(EntityInterface $entity, $langcode = N return $translation; } + /** + * Translates a string to the current language or to a given language. + * + * See the t() documentation for details. + */ + protected function t($string, array $args = array(), array $options = array()) { + return $this->translationManager->translate($string, $args, $options); + } + } diff --git a/core/lib/Drupal/Core/Entity/EntityType.php b/core/lib/Drupal/Core/Entity/EntityType.php index 7c062d0..22b7834 100644 --- a/core/lib/Drupal/Core/Entity/EntityType.php +++ b/core/lib/Drupal/Core/Entity/EntityType.php @@ -609,7 +609,16 @@ public function getGroup() { * {@inheritdoc} */ public function getGroupLabel() { - return !empty($this->group_label) ? $this->group_label : \Drupal::translation()->translate('Other', array(), array('context' => 'Entity type group')); + return !empty($this->group_label) ? $this->group_label : $this->t('Other', array(), array('context' => 'Entity type group')); + } + + /** + * Translates a string to the current language or to a given language. + * + * See the t() documentation for details. + */ + protected function t($string, array $args = array(), array $options = array()) { + return \Drupal::translation()->translate($string, $args, $options); } }