diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index ae3f55a..c1e0f25 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -534,6 +534,23 @@ function t($string, array $args = array(), array $options = array()) { } /** + * A no-op counterpart to t() to mark strings as translatable. + * + * Used to mark string clearly as translatable for tools like potx. + * + * @see https://drupal.org/project/potx + * + * @param $string + * String to mark as translatable. + * + * @return + * The string passed as-is. + */ +function nt($string) { + return $string; +} + +/** * Formats a string for HTML display by replacing variable placeholders. * * @see \Drupal\Component\Utility\String::format() diff --git a/core/lib/Drupal/Core/Entity/FieldableEntityInterface.php b/core/lib/Drupal/Core/Entity/FieldableEntityInterface.php index 24a74be..e11014c 100644 --- a/core/lib/Drupal/Core/Entity/FieldableEntityInterface.php +++ b/core/lib/Drupal/Core/Entity/FieldableEntityInterface.php @@ -37,7 +37,7 @@ * for example a 'name' field could be defined as the following: * @code * $fields['name'] = BaseFieldDefinition::create('string') - * ->setLabel(t('Name')); + * ->setLabel(nt('Name')); * @endcode * * By definition, base fields are fields that exist for every bundle. To diff --git a/core/lib/Drupal/Core/Field/BaseFieldDefinition.php b/core/lib/Drupal/Core/Field/BaseFieldDefinition.php index a96bdd4..4ad4fcd 100644 --- a/core/lib/Drupal/Core/Field/BaseFieldDefinition.php +++ b/core/lib/Drupal/Core/Field/BaseFieldDefinition.php @@ -530,10 +530,10 @@ protected function getFieldItemClass() { * {@inheritdoc} */ public function __sleep() { + $vars = parent::__sleep(); // Do not serialize the statically cached property definitions. - $vars = get_object_vars($this); - unset($vars['propertyDefinitions']); - return array_keys($vars); + unset($vars[array_search('propertyDefinitions', $vars)]); + return $vars; } /** diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/BooleanItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/BooleanItem.php index 2fb8242..fc4358d 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/BooleanItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/BooleanItem.php @@ -43,7 +43,7 @@ public static function defaultStorageSettings() { */ public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) { $properties['value'] = DataDefinition::create('boolean') - ->setLabel(t('Boolean value')); + ->setLabel(nt('Boolean value')); return $properties; } diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/DecimalItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/DecimalItem.php index 1e241f9..ce5e436 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/DecimalItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/DecimalItem.php @@ -41,7 +41,7 @@ public static function defaultStorageSettings() { */ public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) { $properties['value'] = DataDefinition::create('string') - ->setLabel(t('Decimal value')); + ->setLabel(nt('Decimal value')); return $properties; } diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EmailItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EmailItem.php index 38c434a..95a860a 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EmailItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EmailItem.php @@ -32,7 +32,7 @@ class EmailItem extends FieldItemBase { */ public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) { $properties['value'] = DataDefinition::create('email') - ->setLabel(t('E-mail')); + ->setLabel(nt('E-mail')); return $properties; } diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php index ae21f53..59339c8 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php @@ -67,17 +67,17 @@ public static function propertyDefinitions(FieldStorageDefinitionInterface $fiel // @todo: Lookup the entity type's ID data type and use it here. // https://drupal.org/node/2107249 $target_id_definition = DataDefinition::create('integer') - ->setLabel(t('@label ID', array($target_type_info->getLabel()))) + ->setLabel(nt('@label ID'), array($target_type_info->getLabel())) ->setSetting('unsigned', TRUE); } else { $target_id_definition = DataDefinition::create('string') - ->setLabel(t('@label ID', array($target_type_info->getLabel()))); + ->setLabel(nt('@label ID'), array($target_type_info->getLabel())); } $properties['target_id'] = $target_id_definition; $properties['entity'] = DataReferenceDefinition::create('entity') - ->setLabel($target_type_info->getLabel()) - ->setDescription(t('The referenced entity')) + ->setLabel($target_type_info->getLabel(), NULL) + ->setDescription(nt('The referenced entity')) // The entity object is computed out of the entity ID. ->setComputed(TRUE) ->setReadOnly(FALSE) diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/FloatItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/FloatItem.php index 038d4e1..b3cabd6 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/FloatItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/FloatItem.php @@ -29,7 +29,7 @@ class FloatItem extends NumericItemBase { */ public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) { $properties['value'] = DataDefinition::create('float') - ->setLabel(t('Float')); + ->setLabel(nt('Float')); return $properties; } diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/IntegerItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/IntegerItem.php index a2f569b..f2f1ec0 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/IntegerItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/IntegerItem.php @@ -53,7 +53,7 @@ public static function defaultFieldSettings() { */ public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) { $properties['value'] = DataDefinition::create('integer') - ->setLabel(t('Integer value')); + ->setLabel(nt('Integer value')); return $properties; } diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LanguageItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LanguageItem.php index 961eb67..5cf430f 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LanguageItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LanguageItem.php @@ -35,11 +35,11 @@ class LanguageItem extends FieldItemBase { */ public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) { $properties['value'] = DataDefinition::create('string') - ->setLabel(t('Language code')); + ->setLabel(nt('Language code')); $properties['language'] = DataReferenceDefinition::create('language') - ->setLabel(t('Language object')) - ->setDescription(t('The referenced language')) + ->setLabel(nt('Language object')) + ->setDescription(nt('The referenced language')) // The language object is retrieved via the language code. ->setComputed(TRUE) ->setReadOnly(FALSE); diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItemBase.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItemBase.php index c1ff41b..fb2182f 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItemBase.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItemBase.php @@ -9,7 +9,6 @@ use Drupal\Core\Field\FieldItemBase; use Drupal\Core\Field\FieldStorageDefinitionInterface; -use Drupal\Core\StringTranslation\TranslationWrapper; use Drupal\Core\TypedData\DataDefinition; /** @@ -21,10 +20,8 @@ * {@inheritdoc} */ public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) { - // This is called very early by the user entity roles field. Prevent - // early t() calls by using the TranslationWrapper. $properties['value'] = DataDefinition::create('string') - ->setLabel(new TranslationWrapper('Text value')); + ->setLabel(nt('Text value')); return $properties; } diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/TimestampItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/TimestampItem.php index d355287..a68a8e7 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/TimestampItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/TimestampItem.php @@ -40,7 +40,7 @@ class TimestampItem extends FieldItemBase { */ public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) { $properties['value'] = DataDefinition::create('timestamp') - ->setLabel(t('Timestamp value')); + ->setLabel(nt('Timestamp value')); return $properties; } diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/UriItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/UriItem.php index a50696b..01957f8 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/UriItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/UriItem.php @@ -41,7 +41,7 @@ public static function defaultStorageSettings() { */ public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) { $properties['value'] = DataDefinition::create('uri') - ->setLabel(t('URI value')); + ->setLabel(nt('URI value')); return $properties; } diff --git a/core/lib/Drupal/Core/TypedData/DataDefinition.php b/core/lib/Drupal/Core/TypedData/DataDefinition.php index 6f06cf3..4a95e64 100644 --- a/core/lib/Drupal/Core/TypedData/DataDefinition.php +++ b/core/lib/Drupal/Core/TypedData/DataDefinition.php @@ -7,11 +7,21 @@ namespace Drupal\Core\TypedData; +use Drupal\Core\DependencyInjection\DependencySerializationTrait; +use Drupal\Core\StringTranslation\StringTranslationTrait; + /** * A typed data definition class for defining data based on defined data types. */ class DataDefinition implements DataDefinitionInterface, \ArrayAccess { + use StringTranslationTrait; + + use DependencySerializationTrait { + __sleep as traitSleep; + } + + /** * The array holding values for all definition keys. * @@ -75,7 +85,10 @@ public function setDataType($type) { * {@inheritdoc} */ public function getLabel() { - return isset($this->definition['label']) ? $this->definition['label'] : NULL; + if (isset($this->definition['label_arguments'])) { + return $this->t($this->definition['label'], $this->definition['label_arguments']); + } + return isset($this->definition['label']) ? $this->t($this->definition['label']) : NULL; } /** @@ -83,12 +96,17 @@ public function getLabel() { * * @param string $label * The label to set. + * @param array $arguments + * An associative array of replacements to make after translation. Based + * on the first character of the key, the value is escaped and/or themed. + * See \Drupal\Component\Utility\String::format() for details. * * @return static * The object itself for chaining. */ - public function setLabel($label) { + public function setLabel($label, $arguments = array()) { $this->definition['label'] = $label; + $this->definition['label_arguments'] = $arguments; return $this; } @@ -96,7 +114,10 @@ public function setLabel($label) { * {@inheritdoc} */ public function getDescription() { - return isset($this->definition['description']) ? $this->definition['description'] : NULL; + if (isset($this->definition['description_arguments'])) { + return $this->t($this->definition['description'], $this->definition['description_arguments']); + } + return isset($this->definition['description']) ? $this->t($this->definition['description']) : NULL; } /** @@ -104,12 +125,17 @@ public function getDescription() { * * @param string $description * The description to set. + * @param array $arguments + * An associative array of replacements to make after translation. Based + * on the first character of the key, the value is escaped and/or themed. + * See \Drupal\Component\Utility\String::format() for details. * * @return static * The object itself for chaining. */ - public function setDescription($description) { + public function setDescription($description, $arguments = array()) { $this->definition['description'] = $description; + $this->definition['description_arguments'] = $arguments; return $this; } @@ -368,4 +394,11 @@ public function toArray() { return $this->definition; } + /** + * {@inheritdoc} + */ + public function __sleep() { + return $this->traitSleep(); + } + } diff --git a/core/modules/aggregator/src/Entity/Feed.php b/core/modules/aggregator/src/Entity/Feed.php index 6532f36..5bff564 100644 --- a/core/modules/aggregator/src/Entity/Feed.php +++ b/core/modules/aggregator/src/Entity/Feed.php @@ -130,19 +130,19 @@ public static function postDelete(EntityStorageInterface $storage, array $entiti */ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { $fields['fid'] = BaseFieldDefinition::create('integer') - ->setLabel(t('Feed ID')) - ->setDescription(t('The ID of the aggregator feed.')) + ->setLabel(nt('Feed ID')) + ->setDescription(nt('The ID of the aggregator feed.')) ->setReadOnly(TRUE) ->setSetting('unsigned', TRUE); $fields['uuid'] = BaseFieldDefinition::create('uuid') - ->setLabel(t('UUID')) - ->setDescription(t('The aggregator feed UUID.')) + ->setLabel(nt('UUID')) + ->setDescription(nt('The aggregator feed UUID.')) ->setReadOnly(TRUE); $fields['title'] = BaseFieldDefinition::create('string') - ->setLabel(t('Title')) - ->setDescription(t('The name of the feed (or the name of the website providing the feed).')) + ->setLabel(nt('Title')) + ->setDescription(nt('The name of the feed (or the name of the website providing the feed).')) ->setRequired(TRUE) ->setSetting('max_length', 255) ->setDisplayOptions('form', array( @@ -152,12 +152,12 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ->setDisplayConfigurable('form', TRUE); $fields['langcode'] = BaseFieldDefinition::create('language') - ->setLabel(t('Language code')) - ->setDescription(t('The feed language code.')); + ->setLabel(nt('Language code')) + ->setDescription(nt('The feed language code.')); $fields['url'] = BaseFieldDefinition::create('uri') - ->setLabel(t('URL')) - ->setDescription(t('The fully-qualified URL of the feed.')) + ->setLabel(nt('URL')) + ->setDescription(nt('The fully-qualified URL of the feed.')) ->setRequired(TRUE) ->setDisplayOptions('form', array( 'type' => 'uri', @@ -170,8 +170,8 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { $period[AGGREGATOR_CLEAR_NEVER] = t('Never'); $fields['refresh'] = BaseFieldDefinition::create('list_integer') - ->setLabel(t('Update interval')) - ->setDescription(t('The length of time between feed updates. Requires a correctly configured cron maintenance task.')) + ->setLabel(nt('Update interval')) + ->setDescription(nt('The length of time between feed updates. Requires a correctly configured cron maintenance task.')) ->setSetting('unsigned', TRUE) ->setRequired(TRUE) ->setSetting('allowed_values', $period) @@ -182,8 +182,8 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ->setDisplayConfigurable('form', TRUE); $fields['checked'] = BaseFieldDefinition::create('timestamp') - ->setLabel(t('Checked')) - ->setDescription(t('Last time feed was checked for new items, as Unix timestamp.')) + ->setLabel(nt('Checked')) + ->setDescription(nt('Last time feed was checked for new items, as Unix timestamp.')) ->setDefaultValue(0) ->setDisplayOptions('view', array( 'label' => 'inline', @@ -193,13 +193,13 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ->setDisplayConfigurable('view', TRUE); $fields['queued'] = BaseFieldDefinition::create('timestamp') - ->setLabel(t('Queued')) - ->setDescription(t('Time when this feed was queued for refresh, 0 if not queued.')) + ->setLabel(nt('Queued')) + ->setDescription(nt('Time when this feed was queued for refresh, 0 if not queued.')) ->setDefaultValue(0); $fields['link'] = BaseFieldDefinition::create('uri') - ->setLabel(t('URL')) - ->setDescription(t('The link of the feed.')) + ->setLabel(nt('URL')) + ->setDescription(nt('The link of the feed.')) ->setDisplayOptions('view', array( 'label' => 'inline', 'weight' => 4, @@ -207,26 +207,26 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ->setDisplayConfigurable('view', TRUE); $fields['description'] = BaseFieldDefinition::create('string_long') - ->setLabel(t('Description')) - ->setDescription(t("The parent website's description that comes from the !description element in the feed.", array('!description' => ''))); + ->setLabel(nt('Description')) + ->setDescription(nt("The parent website's description that comes from the !description element in the feed."), array('!description' => '')); $fields['image'] = BaseFieldDefinition::create('uri') - ->setLabel(t('Image')) - ->setDescription(t('An image representing the feed.')); + ->setLabel(nt('Image')) + ->setDescription(nt('An image representing the feed.')); $fields['hash'] = BaseFieldDefinition::create('string') - ->setLabel(t('Hash')) - ->setDescription(t('Calculated hash of the feed data, used for validating cache.')); + ->setLabel(nt('Hash')) + ->setDescription(nt('Calculated hash of the feed data, used for validating cache.')); $fields['etag'] = BaseFieldDefinition::create('string') - ->setLabel(t('Etag')) - ->setDescription(t('Entity tag HTTP response header, used for validating cache.')); + ->setLabel(nt('Etag')) + ->setDescription(nt('Entity tag HTTP response header, used for validating cache.')); // This is updated by the fetcher and not when the feed is saved, therefore // it's a timestamp and not a changed field. $fields['modified'] = BaseFieldDefinition::create('timestamp') - ->setLabel(t('Modified')) - ->setDescription(t('When the feed was last modified, as a Unix timestamp.')); + ->setLabel(nt('Modified')) + ->setDescription(nt('When the feed was last modified, as a Unix timestamp.')); return $fields; } diff --git a/core/modules/aggregator/src/Entity/Item.php b/core/modules/aggregator/src/Entity/Item.php index 066b7ff..3aa269f 100644 --- a/core/modules/aggregator/src/Entity/Item.php +++ b/core/modules/aggregator/src/Entity/Item.php @@ -52,14 +52,14 @@ public function label() { */ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { $fields['iid'] = BaseFieldDefinition::create('integer') - ->setLabel(t('Aggregator item ID')) - ->setDescription(t('The ID of the feed item.')) + ->setLabel(nt('Aggregator item ID')) + ->setDescription(nt('The ID of the feed item.')) ->setReadOnly(TRUE) ->setSetting('unsigned', TRUE); $fields['fid'] = BaseFieldDefinition::create('entity_reference') - ->setLabel(t('Source feed')) - ->setDescription(t('The aggregator feed entity associated with this item.')) + ->setLabel(nt('Source feed')) + ->setDescription(nt('The aggregator feed entity associated with this item.')) ->setSetting('target_type', 'aggregator_feed') ->setDisplayOptions('view', array( 'label' => 'hidden', @@ -69,24 +69,24 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ->setDisplayConfigurable('form', TRUE); $fields['title'] = BaseFieldDefinition::create('string') - ->setLabel(t('Title')) - ->setDescription(t('The title of the feed item.')); + ->setLabel(nt('Title')) + ->setDescription(nt('The title of the feed item.')); $fields['langcode'] = BaseFieldDefinition::create('language') - ->setLabel(t('Language code')) - ->setDescription(t('The feed item language code.')); + ->setLabel(nt('Language code')) + ->setDescription(nt('The feed item language code.')); $fields['link'] = BaseFieldDefinition::create('uri') - ->setLabel(t('Link')) - ->setDescription(t('The link of the feed item.')) + ->setLabel(nt('Link')) + ->setDescription(nt('The link of the feed item.')) ->setDisplayOptions('view', array( 'type' => 'hidden', )) ->setDisplayConfigurable('view', TRUE); $fields['author'] = BaseFieldDefinition::create('string') - ->setLabel(t('Author')) - ->setDescription(t('The author of the feed item.')) + ->setLabel(nt('Author')) + ->setDescription(nt('The author of the feed item.')) ->setDisplayOptions('view', array( 'label' => 'hidden', 'weight' => 3, @@ -94,12 +94,12 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ->setDisplayConfigurable('view', TRUE); $fields['description'] = BaseFieldDefinition::create('string_long') - ->setLabel(t('Description')) - ->setDescription(t('The body of the feed item.')); + ->setLabel(nt('Description')) + ->setDescription(nt('The body of the feed item.')); $fields['timestamp'] = BaseFieldDefinition::create('created') - ->setLabel(t('Posted on')) - ->setDescription(t('Posted date of the feed item, as a Unix timestamp.')) + ->setLabel(nt('Posted on')) + ->setDescription(nt('Posted date of the feed item, as a Unix timestamp.')) ->setDisplayOptions('view', array( 'label' => 'hidden', 'type' => 'timestamp_ago', @@ -109,8 +109,8 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { // @todo Convert to a real UUID field in https://drupal.org/node/2149851. $fields['guid'] = BaseFieldDefinition::create('string_long') - ->setLabel(t('GUID')) - ->setDescription(t('Unique identifier for the feed item.')); + ->setLabel(nt('GUID')) + ->setDescription(nt('Unique identifier for the feed item.')); return $fields; } diff --git a/core/modules/block_content/src/Entity/BlockContent.php b/core/modules/block_content/src/Entity/BlockContent.php index e2320bd..b85a32a 100644 --- a/core/modules/block_content/src/Entity/BlockContent.php +++ b/core/modules/block_content/src/Entity/BlockContent.php @@ -139,30 +139,30 @@ public function delete() { */ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { $fields['id'] = BaseFieldDefinition::create('integer') - ->setLabel(t('Custom block ID')) - ->setDescription(t('The custom block ID.')) + ->setLabel(nt('Custom block ID')) + ->setDescription(nt('The custom block ID.')) ->setReadOnly(TRUE) ->setSetting('unsigned', TRUE); $fields['uuid'] = BaseFieldDefinition::create('uuid') - ->setLabel(t('UUID')) - ->setDescription(t('The custom block UUID.')) + ->setLabel(nt('UUID')) + ->setDescription(nt('The custom block UUID.')) ->setReadOnly(TRUE); $fields['revision_id'] = BaseFieldDefinition::create('integer') - ->setLabel(t('Revision ID')) - ->setDescription(t('The revision ID.')) + ->setLabel(nt('Revision ID')) + ->setDescription(nt('The revision ID.')) ->setReadOnly(TRUE) ->setSetting('unsigned', TRUE); $fields['langcode'] = BaseFieldDefinition::create('language') - ->setLabel(t('Language code')) - ->setDescription(t('The custom block language code.')) + ->setLabel(nt('Language code')) + ->setDescription(nt('The custom block language code.')) ->setRevisionable(TRUE); $fields['info'] = BaseFieldDefinition::create('string') - ->setLabel(t('Block description')) - ->setDescription(t('A brief description of your block.')) + ->setLabel(nt('Block description')) + ->setDescription(nt('A brief description of your block.')) ->setRevisionable(TRUE) ->setTranslatable(TRUE) ->setRequired(TRUE) @@ -173,18 +173,18 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ->setDisplayConfigurable('form', TRUE); $fields['type'] = BaseFieldDefinition::create('entity_reference') - ->setLabel(t('Block type')) - ->setDescription(t('The block type.')) + ->setLabel(nt('Block type')) + ->setDescription(nt('The block type.')) ->setSetting('target_type', 'block_content_type'); $fields['revision_log'] = BaseFieldDefinition::create('string_long') - ->setLabel(t('Revision log message')) - ->setDescription(t('The log entry explaining the changes in this revision.')) + ->setLabel(nt('Revision log message')) + ->setDescription(nt('The log entry explaining the changes in this revision.')) ->setRevisionable(TRUE); $fields['changed'] = BaseFieldDefinition::create('changed') - ->setLabel(t('Changed')) - ->setDescription(t('The time that the custom block was last edited.')) + ->setLabel(nt('Changed')) + ->setDescription(nt('The time that the custom block was last edited.')) ->setRevisionable(TRUE); return $fields; diff --git a/core/modules/comment/src/Entity/Comment.php b/core/modules/comment/src/Entity/Comment.php index 57c7287..c8eec73 100644 --- a/core/modules/comment/src/Entity/Comment.php +++ b/core/modules/comment/src/Entity/Comment.php @@ -200,32 +200,32 @@ public function permalink() { */ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { $fields['cid'] = BaseFieldDefinition::create('integer') - ->setLabel(t('Comment ID')) - ->setDescription(t('The comment ID.')) + ->setLabel(nt('Comment ID')) + ->setDescription(nt('The comment ID.')) ->setReadOnly(TRUE) ->setSetting('unsigned', TRUE); $fields['uuid'] = BaseFieldDefinition::create('uuid') - ->setLabel(t('UUID')) - ->setDescription(t('The comment UUID.')) + ->setLabel(nt('UUID')) + ->setDescription(nt('The comment UUID.')) ->setReadOnly(TRUE); $fields['pid'] = BaseFieldDefinition::create('entity_reference') - ->setLabel(t('Parent ID')) - ->setDescription(t('The parent comment ID if this is a reply to a comment.')) + ->setLabel(nt('Parent ID')) + ->setDescription(nt('The parent comment ID if this is a reply to a comment.')) ->setSetting('target_type', 'comment'); $fields['entity_id'] = BaseFieldDefinition::create('entity_reference') - ->setLabel(t('Entity ID')) - ->setDescription(t('The ID of the entity of which this comment is a reply.')) + ->setLabel(nt('Entity ID')) + ->setDescription(nt('The ID of the entity of which this comment is a reply.')) ->setRequired(TRUE); $fields['langcode'] = BaseFieldDefinition::create('language') - ->setLabel(t('Language code')) - ->setDescription(t('The comment language code.')); + ->setLabel(nt('Language code')) + ->setDescription(nt('The comment language code.')); $fields['subject'] = BaseFieldDefinition::create('string') - ->setLabel(t('Subject')) + ->setLabel(nt('Subject')) ->setTranslatable(TRUE) ->setSetting('max_length', 64) ->setDisplayOptions('form', array( @@ -236,73 +236,73 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ->setDisplayConfigurable('form', TRUE); $fields['uid'] = BaseFieldDefinition::create('entity_reference') - ->setLabel(t('User ID')) - ->setDescription(t('The user ID of the comment author.')) + ->setLabel(nt('User ID')) + ->setDescription(nt('The user ID of the comment author.')) ->setTranslatable(TRUE) ->setSetting('target_type', 'user') ->setDefaultValue(0); $fields['name'] = BaseFieldDefinition::create('string') - ->setLabel(t('Name')) - ->setDescription(t("The comment author's name.")) + ->setLabel(nt('Name')) + ->setDescription(nt("The comment author's name.")) ->setTranslatable(TRUE) ->setSetting('max_length', 60) ->setDefaultValue('') ->addConstraint('CommentName', array()); $fields['mail'] = BaseFieldDefinition::create('email') - ->setLabel(t('Email')) - ->setDescription(t("The comment author's email address.")) + ->setLabel(nt('Email')) + ->setDescription(nt("The comment author's email address.")) ->setTranslatable(TRUE); $fields['homepage'] = BaseFieldDefinition::create('uri') - ->setLabel(t('Homepage')) - ->setDescription(t("The comment author's home page address.")) + ->setLabel(nt('Homepage')) + ->setDescription(nt("The comment author's home page address.")) ->setTranslatable(TRUE) // URIs are not length limited by RFC 2616, but we can only store 255 // characters in our comment DB schema. ->setSetting('max_length', 255); $fields['hostname'] = BaseFieldDefinition::create('string') - ->setLabel(t('Hostname')) - ->setDescription(t("The comment author's hostname.")) + ->setLabel(nt('Hostname')) + ->setDescription(nt("The comment author's hostname.")) ->setTranslatable(TRUE) ->setSetting('max_length', 128); $fields['created'] = BaseFieldDefinition::create('created') - ->setLabel(t('Created')) - ->setDescription(t('The time that the comment was created.')) + ->setLabel(nt('Created')) + ->setDescription(nt('The time that the comment was created.')) ->setTranslatable(TRUE); $fields['changed'] = BaseFieldDefinition::create('changed') - ->setLabel(t('Changed')) - ->setDescription(t('The time that the comment was last edited.')) + ->setLabel(nt('Changed')) + ->setDescription(nt('The time that the comment was last edited.')) ->setTranslatable(TRUE); $fields['status'] = BaseFieldDefinition::create('boolean') - ->setLabel(t('Publishing status')) - ->setDescription(t('A boolean indicating whether the comment is published.')) + ->setLabel(nt('Publishing status')) + ->setDescription(nt('A boolean indicating whether the comment is published.')) ->setTranslatable(TRUE) ->setDefaultValue(TRUE); $fields['thread'] = BaseFieldDefinition::create('string') - ->setLabel(t('Thread place')) - ->setDescription(t("The alphadecimal representation of the comment's place in a thread, consisting of a base 36 string prefixed by an integer indicating its length.")) + ->setLabel(nt('Thread place')) + ->setDescription(nt("The alphadecimal representation of the comment's place in a thread, consisting of a base 36 string prefixed by an integer indicating its length.")) ->setSetting('max_length', 255); $fields['entity_type'] = BaseFieldDefinition::create('string') - ->setLabel(t('Entity type')) - ->setDescription(t('The entity type to which this comment is attached.')) + ->setLabel(nt('Entity type')) + ->setDescription(nt('The entity type to which this comment is attached.')) ->setSetting('max_length', EntityTypeInterface::ID_MAX_LENGTH); $fields['comment_type'] = BaseFieldDefinition::create('entity_reference') - ->setLabel(t('Comment Type')) - ->setDescription(t('The comment type.')) + ->setLabel(nt('Comment Type')) + ->setDescription(nt('The comment type.')) ->setSetting('target_type', 'comment_type'); $fields['field_name'] = BaseFieldDefinition::create('string') - ->setLabel(t('Comment field name')) - ->setDescription(t('The field name through which this comment was added.')) + ->setLabel(nt('Comment field name')) + ->setDescription(nt('The field name through which this comment was added.')) ->setSetting('max_length', FieldStorageConfig::NAME_MAX_LENGTH); return $fields; diff --git a/core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php b/core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php index 93274a5..5b7745c 100644 --- a/core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php +++ b/core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php @@ -55,25 +55,25 @@ public static function defaultFieldSettings() { */ public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) { $properties['status'] = DataDefinition::create('integer') - ->setLabel(t('Comment status')); + ->setLabel(nt('Comment status')); $properties['cid'] = DataDefinition::create('integer') - ->setLabel(t('Last comment ID')); + ->setLabel(nt('Last comment ID')); $properties['last_comment_timestamp'] = DataDefinition::create('integer') - ->setLabel(t('Last comment timestamp')) - ->setDescription(t('The time that the last comment was created.')); + ->setLabel(nt('Last comment timestamp')) + ->setDescription(nt('The time that the last comment was created.')); $properties['last_comment_name'] = DataDefinition::create('string') - ->setLabel(t('Last comment name')) - ->setDescription(t('The name of the user posting the last comment.')); + ->setLabel(nt('Last comment name')) + ->setDescription(nt('The name of the user posting the last comment.')); $properties['last_comment_uid'] = DataDefinition::create('integer') - ->setLabel(t('Last comment user ID')); + ->setLabel(nt('Last comment user ID')); $properties['comment_count'] = DataDefinition::create('integer') - ->setLabel(t('Number of comments')) - ->setDescription(t('The number of comments.')); + ->setLabel(nt('Number of comments')) + ->setDescription(nt('The number of comments.')); return $properties; } diff --git a/core/modules/contact/src/Entity/Message.php b/core/modules/contact/src/Entity/Message.php index 20be2e8..0e1bf0f 100644 --- a/core/modules/contact/src/Entity/Message.php +++ b/core/modules/contact/src/Entity/Message.php @@ -133,31 +133,31 @@ public function getPersonalRecipient() { */ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { $fields['contact_form'] = BaseFieldDefinition::create('entity_reference') - ->setLabel(t('Form ID')) - ->setDescription(t('The ID of the associated form.')) + ->setLabel(nt('Form ID')) + ->setDescription(nt('The ID of the associated form.')) ->setSetting('target_type', 'contact_form') ->setRequired(TRUE); $fields['uuid'] = BaseFieldDefinition::create('uuid') - ->setLabel(t('UUID')) - ->setDescription(t('The message UUID.')) + ->setLabel(nt('UUID')) + ->setDescription(nt('The message UUID.')) ->setReadOnly(TRUE); $fields['langcode'] = BaseFieldDefinition::create('language') - ->setLabel(t('Language code')) - ->setDescription(t('The comment language code.')); + ->setLabel(nt('Language code')) + ->setDescription(nt('The comment language code.')); $fields['name'] = BaseFieldDefinition::create('string') - ->setLabel(t("The sender's name")) - ->setDescription(t('The name of the person that is sending the contact message.')); + ->setLabel(nt("The sender's name")) + ->setDescription(nt('The name of the person that is sending the contact message.')); $fields['mail'] = BaseFieldDefinition::create('email') - ->setLabel(t("The sender's email")) - ->setDescription(t('The email of the person that is sending the contact message.')); + ->setLabel(nt("The sender's email")) + ->setDescription(nt('The email of the person that is sending the contact message.')); // The subject of the contact message. $fields['subject'] = BaseFieldDefinition::create('string') - ->setLabel(t('Subject')) + ->setLabel(nt('Subject')) ->setRequired(TRUE) ->setSetting('max_length', 100) ->setDisplayOptions('form', array( @@ -168,7 +168,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { // The text of the contact message. $fields['message'] = BaseFieldDefinition::create('string_long') - ->setLabel(t('Message')) + ->setLabel(nt('Message')) ->setRequired(TRUE) ->setDisplayOptions('form', array( 'type' => 'string_textarea', @@ -186,12 +186,12 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ->setDisplayConfigurable('view', TRUE); $fields['copy'] = BaseFieldDefinition::create('boolean') - ->setLabel(t('Copy')) - ->setDescription(t('Whether to send a copy of the message to the sender.')); + ->setLabel(nt('Copy')) + ->setDescription(nt('Whether to send a copy of the message to the sender.')); $fields['recipient'] = BaseFieldDefinition::create('entity_reference') - ->setLabel(t('Recipient ID')) - ->setDescription(t('The ID of the recipient user for personal contact messages.')) + ->setLabel(nt('Recipient ID')) + ->setDescription(nt('The ID of the recipient user for personal contact messages.')) ->setSetting('target_type', 'user'); return $fields; diff --git a/core/modules/contact/tests/modules/contact_storage_test/contact_storage_test.module b/core/modules/contact/tests/modules/contact_storage_test/contact_storage_test.module index 0ecfee5..c66bb12 100644 --- a/core/modules/contact/tests/modules/contact_storage_test/contact_storage_test.module +++ b/core/modules/contact/tests/modules/contact_storage_test/contact_storage_test.module @@ -17,8 +17,8 @@ function contact_storage_test_entity_base_field_info(\Drupal\Core\Entity\EntityT $fields = array(); $fields['id'] = BaseFieldDefinition::create('integer') - ->setLabel(t('Message ID')) - ->setDescription(t('The message ID.')) + ->setLabel(nt('Message ID')) + ->setDescription(nt('The message ID.')) ->setReadOnly(TRUE) ->setSetting('unsigned', TRUE); diff --git a/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeItem.php b/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeItem.php index f63ffd6..f14debb 100644 --- a/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeItem.php +++ b/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeItem.php @@ -51,11 +51,11 @@ public static function defaultStorageSettings() { */ public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) { $properties['value'] = DataDefinition::create('datetime_iso8601') - ->setLabel(t('Date value')); + ->setLabel(nt('Date value')); $properties['date'] = DataDefinition::create('any') - ->setLabel(t('Computed date')) - ->setDescription(t('The computed DateTime object.')) + ->setLabel(nt('Computed date')) + ->setDescription(nt('The computed DateTime object.')) ->setComputed(TRUE) ->setClass('\Drupal\datetime\DateTimeComputed') ->setSetting('date source', 'value'); diff --git a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/HiddenTestItem.php b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/HiddenTestItem.php index b145abe..353e484 100644 --- a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/HiddenTestItem.php +++ b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/HiddenTestItem.php @@ -29,7 +29,7 @@ class HiddenTestItem extends TestItem { */ public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) { $properties['value'] = DataDefinition::create('integer') - ->setLabel(t('Test integer value')); + ->setLabel(nt('Test integer value')); return $properties; } diff --git a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItem.php b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItem.php index 456f911..07eabbd 100644 --- a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItem.php +++ b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItem.php @@ -50,7 +50,7 @@ public static function defaultFieldSettings() { */ public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) { $properties['value'] = DataDefinition::create('integer') - ->setLabel(t('Test integer value')); + ->setLabel(nt('Test integer value')); return $properties; } diff --git a/core/modules/file/src/Entity/File.php b/core/modules/file/src/Entity/File.php index b21a182..c7e02b1 100644 --- a/core/modules/file/src/Entity/File.php +++ b/core/modules/file/src/Entity/File.php @@ -234,55 +234,55 @@ public static function preDelete(EntityStorageInterface $storage, array $entitie */ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { $fields['fid'] = BaseFieldDefinition::create('integer') - ->setLabel(t('File ID')) - ->setDescription(t('The file ID.')) + ->setLabel(nt('File ID')) + ->setDescription(nt('The file ID.')) ->setReadOnly(TRUE) ->setSetting('unsigned', TRUE); $fields['uuid'] = BaseFieldDefinition::create('uuid') - ->setLabel(t('UUID')) - ->setDescription(t('The file UUID.')) + ->setLabel(nt('UUID')) + ->setDescription(nt('The file UUID.')) ->setReadOnly(TRUE); $fields['langcode'] = BaseFieldDefinition::create('language') - ->setLabel(t('Language code')) - ->setDescription(t('The file language code.')); + ->setLabel(nt('Language code')) + ->setDescription(nt('The file language code.')); $fields['uid'] = BaseFieldDefinition::create('entity_reference') - ->setLabel(t('User ID')) - ->setDescription(t('The user ID of the file.')) + ->setLabel(nt('User ID')) + ->setDescription(nt('The user ID of the file.')) ->setSetting('target_type', 'user'); $fields['filename'] = BaseFieldDefinition::create('string') - ->setLabel(t('Filename')) - ->setDescription(t('Name of the file with no path components.')); + ->setLabel(nt('Filename')) + ->setDescription(nt('Name of the file with no path components.')); $fields['uri'] = BaseFieldDefinition::create('uri') - ->setLabel(t('URI')) - ->setDescription(t('The URI to access the file (either local or remote).')) + ->setLabel(nt('URI')) + ->setDescription(nt('The URI to access the file (either local or remote).')) ->setSetting('max_length', 255); $fields['filemime'] = BaseFieldDefinition::create('string') - ->setLabel(t('File MIME type')) - ->setDescription(t("The file's MIME type.")); + ->setLabel(nt('File MIME type')) + ->setDescription(nt("The file's MIME type.")); $fields['filesize'] = BaseFieldDefinition::create('integer') - ->setLabel(t('File size')) - ->setDescription(t('The size of the file in bytes.')) + ->setLabel(nt('File size')) + ->setDescription(nt('The size of the file in bytes.')) ->setSetting('unsigned', TRUE) ->setSetting('size', 'big'); $fields['status'] = BaseFieldDefinition::create('boolean') - ->setLabel(t('Status')) - ->setDescription(t('The status of the file, temporary (FALSE) and permanent (TRUE).')); + ->setLabel(nt('Status')) + ->setDescription(nt('The status of the file, temporary (FALSE) and permanent (TRUE).')); $fields['created'] = BaseFieldDefinition::create('created') - ->setLabel(t('Created')) - ->setDescription(t('The timestamp that the file was created.')); + ->setLabel(nt('Created')) + ->setDescription(nt('The timestamp that the file was created.')); $fields['changed'] = BaseFieldDefinition::create('changed') - ->setLabel(t('Changed')) - ->setDescription(t('The timestamp that the file was last changed.')); + ->setLabel(nt('Changed')) + ->setDescription(nt('The timestamp that the file was last changed.')); return $fields; } diff --git a/core/modules/file/src/Plugin/Field/FieldType/FileItem.php b/core/modules/file/src/Plugin/Field/FieldType/FileItem.php index 1c00e76..31999f4 100644 --- a/core/modules/file/src/Plugin/Field/FieldType/FileItem.php +++ b/core/modules/file/src/Plugin/Field/FieldType/FileItem.php @@ -100,11 +100,11 @@ public static function propertyDefinitions(FieldStorageDefinitionInterface $fiel $properties = parent::propertyDefinitions($field_definition); $properties['display'] = DataDefinition::create('boolean') - ->setLabel(t('Display')) - ->setDescription(t('Flag to control whether this file should be displayed when viewing content')); + ->setLabel(nt('Display')) + ->setDescription(nt('Flag to control whether this file should be displayed when viewing content')); $properties['description'] = DataDefinition::create('string') - ->setLabel(t('Description')); + ->setLabel(nt('Description')); return $properties; } diff --git a/core/modules/image/src/Plugin/Field/FieldType/ImageItem.php b/core/modules/image/src/Plugin/Field/FieldType/ImageItem.php index 6d1c149..9fa126e 100644 --- a/core/modules/image/src/Plugin/Field/FieldType/ImageItem.php +++ b/core/modules/image/src/Plugin/Field/FieldType/ImageItem.php @@ -141,20 +141,20 @@ public static function propertyDefinitions(FieldStorageDefinitionInterface $fiel $properties = parent::propertyDefinitions($field_definition); $properties['alt'] = DataDefinition::create('string') - ->setLabel(t('Alternative text')) - ->setDescription(t("Alternative image text, for the image's 'alt' attribute.")); + ->setLabel(nt('Alternative text')) + ->setDescription(nt("Alternative image text, for the image's 'alt' attribute.")); $properties['title'] = DataDefinition::create('string') - ->setLabel(t('Title')) - ->setDescription(t("Image title text, for the image's 'title' attribute.")); + ->setLabel(nt('Title')) + ->setDescription("Image title text, for the image's 'title' attribute."); $properties['width'] = DataDefinition::create('integer') - ->setLabel(t('Width')) - ->setDescription(t('The width of the image in pixels.')); + ->setLabel(nt('Width')) + ->setDescription(nt('The width of the image in pixels.')); $properties['height'] = DataDefinition::create('integer') - ->setLabel(t('Height')) - ->setDescription(t('The height of the image in pixels.')); + ->setLabel(nt('Height')) + ->setDescription(nt('The height of the image in pixels.')); return $properties; } diff --git a/core/modules/link/src/Plugin/Field/FieldType/LinkItem.php b/core/modules/link/src/Plugin/Field/FieldType/LinkItem.php index 37e40d4..37ae41b 100644 --- a/core/modules/link/src/Plugin/Field/FieldType/LinkItem.php +++ b/core/modules/link/src/Plugin/Field/FieldType/LinkItem.php @@ -45,19 +45,19 @@ public static function defaultFieldSettings() { */ public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) { $properties['url'] = DataDefinition::create('string') - ->setLabel(t('URL')); + ->setLabel(nt('URL')); $properties['title'] = DataDefinition::create('string') - ->setLabel(t('Link text')); + ->setLabel(nt('Link text')); $properties['route_name'] = DataDefinition::create('string') - ->setLabel(t('Route name')); + ->setLabel(nt('Route name')); $properties['route_parameters'] = MapDataDefinition::create() - ->setLabel(t('Route parameters')); + ->setLabel(nt('Route parameters')); $properties['options'] = MapDataDefinition::create() - ->setLabel(t('Options')); + ->setLabel(nt('Options')); return $properties; } diff --git a/core/modules/menu_link_content/src/Entity/MenuLinkContent.php b/core/modules/menu_link_content/src/Entity/MenuLinkContent.php index 9b44af0..47fcfe3 100644 --- a/core/modules/menu_link_content/src/Entity/MenuLinkContent.php +++ b/core/modules/menu_link_content/src/Entity/MenuLinkContent.php @@ -269,25 +269,25 @@ public static function preDelete(EntityStorageInterface $storage, array $entitie */ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { $fields['id'] = BaseFieldDefinition::create('integer') - ->setLabel(t('Entity ID')) - ->setDescription(t('The entity ID for this menu link content entity.')) + ->setLabel(nt('Entity ID')) + ->setDescription(nt('The entity ID for this menu link content entity.')) ->setReadOnly(TRUE) ->setSetting('unsigned', TRUE); $fields['uuid'] = BaseFieldDefinition::create('uuid') - ->setLabel(t('UUID')) - ->setDescription(t('The content menu link UUID.')) + ->setLabel(nt('UUID')) + ->setDescription(nt('The content menu link UUID.')) ->setReadOnly(TRUE); $fields['bundle'] = BaseFieldDefinition::create('string') - ->setLabel(t('Bundle')) - ->setDescription(t('The content menu link bundle.')) + ->setLabel(nt('Bundle')) + ->setDescription(nt('The content menu link bundle.')) ->setSetting('max_length', EntityTypeInterface::BUNDLE_MAX_LENGTH) ->setReadOnly(TRUE); $fields['title'] = BaseFieldDefinition::create('string') - ->setLabel(t('Menu link title')) - ->setDescription(t('The text to be used for this link in the menu.')) + ->setLabel(nt('Menu link title')) + ->setDescription(nt('The text to be used for this link in the menu.')) ->setRequired(TRUE) ->setTranslatable(TRUE) ->setSettings(array( @@ -305,8 +305,8 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ->setDisplayConfigurable('form', TRUE); $fields['description'] = BaseFieldDefinition::create('string') - ->setLabel(t('Description')) - ->setDescription(t('Shown when hovering over the menu link.')) + ->setLabel(nt('Description')) + ->setDescription(nt('Shown when hovering over the menu link.')) ->setTranslatable(TRUE) ->setSettings(array( 'max_length' => 255, @@ -322,36 +322,36 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { )); $fields['menu_name'] = BaseFieldDefinition::create('string') - ->setLabel(t('Menu name')) - ->setDescription(t('The menu name. All links with the same menu name (such as "tools") are part of the same menu.')) + ->setLabel(nt('Menu name')) + ->setDescription(nt('The menu name. All links with the same menu name (such as "tools") are part of the same menu.')) ->setSetting('default_value', 'tools'); // @todo Use a link field https://www.drupal.org/node/2302205. $fields['route_name'] = BaseFieldDefinition::create('string') - ->setLabel(t('Route name')) - ->setDescription(t('The machine name of a defined Symfony Route this menu item represents.')); + ->setLabel(nt('Route name')) + ->setDescription(nt('The machine name of a defined Symfony Route this menu item represents.')); $fields['route_parameters'] = BaseFieldDefinition::create('map') - ->setLabel(t('Route parameters')) - ->setDescription(t('A serialized array of route parameters of this menu link.')); + ->setLabel(nt('Route parameters')) + ->setDescription(nt('A serialized array of route parameters of this menu link.')); $fields['url'] = BaseFieldDefinition::create('uri') - ->setLabel(t('External link url')) - ->setDescription(t('The url of the link, in case you have an external link.')); + ->setLabel(nt('External link url')) + ->setDescription(nt('The url of the link, in case you have an external link.')); $fields['options'] = BaseFieldDefinition::create('map') - ->setLabel(t('Options')) - ->setDescription(t('A serialized array of options to be passed to the _url() or _l() function, such as a query string or HTML attributes.')) + ->setLabel(nt('Options')) + ->setDescription(nt('A serialized array of options to be passed to the _url() or _l() function, such as a query string or HTML attributes.')) ->setSetting('default_value', array()); $fields['external'] = BaseFieldDefinition::create('boolean') - ->setLabel(t('External')) - ->setDescription(t('A flag to indicate if the link points to a full URL starting with a protocol, like http:// (1 = external, 0 = internal).')) + ->setLabel(nt('External')) + ->setDescription(nt('A flag to indicate if the link points to a full URL starting with a protocol, like http:// (1 = external, 0 = internal).')) ->setSetting('default_value', FALSE); $fields['weight'] = BaseFieldDefinition::create('integer') - ->setLabel(t('Weight')) - ->setDescription(t('Link weight among links in the same menu at the same depth. In the menu, the links with high weight will sink and links with a low weight will be positioned nearer the top.')) + ->setLabel(nt('Weight')) + ->setDescription(nt('Link weight among links in the same menu at the same depth. In the menu, the links with high weight will sink and links with a low weight will be positioned nearer the top.')) ->setDefaultValue(0) ->setDisplayOptions('view', array( 'label' => 'hidden', @@ -364,8 +364,8 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { )); $fields['expanded'] = BaseFieldDefinition::create('boolean') - ->setLabel(t('Show as expanded')) - ->setDescription(t('If selected and this menu link has children, the menu will always appear expanded.')) + ->setLabel(nt('Show as expanded')) + ->setDescription(nt('If selected and this menu link has children, the menu will always appear expanded.')) ->setDefaultValue(FALSE) ->setDisplayOptions('view', array( 'label' => 'hidden', @@ -378,8 +378,8 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { )); $fields['enabled'] = BaseFieldDefinition::create('boolean') - ->setLabel(t('Enabled')) - ->setDescription(t('A flag for whether the link should be enabled in menus or hidden.')) + ->setLabel(nt('Enabled')) + ->setDescription(nt('A flag for whether the link should be enabled in menus or hidden.')) ->setDefaultValue(TRUE) ->setDisplayOptions('view', array( 'label' => 'hidden', @@ -392,16 +392,16 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { )); $fields['langcode'] = BaseFieldDefinition::create('language') - ->setLabel(t('Language code')) - ->setDescription(t('The node language code.')); + ->setLabel(nt('Language code')) + ->setDescription(nt('The node language code.')); $fields['parent'] = BaseFieldDefinition::create('string') - ->setLabel(t('Parent plugin ID')) - ->setDescription(t('The ID of the parent menu link plugin, or empty string when at the top level of the hierarchy.')); + ->setLabel(nt('Parent plugin ID')) + ->setDescription(nt('The ID of the parent menu link plugin, or empty string when at the top level of the hierarchy.')); $fields['changed'] = BaseFieldDefinition::create('changed') - ->setLabel(t('Changed')) - ->setDescription(t('The time that the menu link was last edited.')); + ->setLabel(nt('Changed')) + ->setDescription(nt('The time that the menu link was last edited.')); return $fields; } diff --git a/core/modules/node/src/Entity/Node.php b/core/modules/node/src/Entity/Node.php index 4b7671f..40c8926 100644 --- a/core/modules/node/src/Entity/Node.php +++ b/core/modules/node/src/Entity/Node.php @@ -324,36 +324,36 @@ public function setRevisionAuthorId($uid) { */ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { $fields['nid'] = BaseFieldDefinition::create('integer') - ->setLabel(t('Node ID')) - ->setDescription(t('The node ID.')) + ->setLabel(nt('Node ID')) + ->setDescription(nt('The node ID.')) ->setReadOnly(TRUE) ->setSetting('unsigned', TRUE); $fields['uuid'] = BaseFieldDefinition::create('uuid') - ->setLabel(t('UUID')) - ->setDescription(t('The node UUID.')) + ->setLabel(nt('UUID')) + ->setDescription(nt('The node UUID.')) ->setReadOnly(TRUE); $fields['vid'] = BaseFieldDefinition::create('integer') - ->setLabel(t('Revision ID')) - ->setDescription(t('The node revision ID.')) + ->setLabel(nt('Revision ID')) + ->setDescription(nt('The node revision ID.')) ->setReadOnly(TRUE) ->setSetting('unsigned', TRUE); $fields['type'] = BaseFieldDefinition::create('entity_reference') - ->setLabel(t('Type')) - ->setDescription(t('The node type.')) + ->setLabel(nt('Type')) + ->setDescription(nt('The node type.')) ->setSetting('target_type', 'node_type') ->setReadOnly(TRUE); $fields['langcode'] = BaseFieldDefinition::create('language') - ->setLabel(t('Language code')) - ->setDescription(t('The node language code.')) + ->setLabel(nt('Language code')) + ->setDescription(nt('The node language code.')) ->setRevisionable(TRUE); $fields['title'] = BaseFieldDefinition::create('string') - ->setLabel(t('Title')) - ->setDescription(t('The title of this node, always treated as non-markup plain text.')) + ->setLabel(nt('Title')) + ->setDescription(nt('The title of this node, always treated as non-markup plain text.')) ->setRequired(TRUE) ->setTranslatable(TRUE) ->setRevisionable(TRUE) @@ -371,8 +371,8 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ->setDisplayConfigurable('form', TRUE); $fields['uid'] = BaseFieldDefinition::create('entity_reference') - ->setLabel(t('Authored by')) - ->setDescription(t('The user ID of the node author.')) + ->setLabel(nt('Authored by')) + ->setDescription(nt('The user ID of the node author.')) ->setRevisionable(TRUE) ->setSetting('target_type', 'user') ->setSetting('handler', 'default') @@ -396,15 +396,15 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ->setDisplayConfigurable('form', TRUE); $fields['status'] = BaseFieldDefinition::create('boolean') - ->setLabel(t('Publishing status')) - ->setDescription(t('A boolean indicating whether the node is published.')) + ->setLabel(nt('Publishing status')) + ->setDescription(nt('A boolean indicating whether the node is published.')) ->setRevisionable(TRUE) ->setTranslatable(TRUE) ->setDefaultValue(TRUE); $fields['created'] = BaseFieldDefinition::create('created') - ->setLabel(t('Authored on')) - ->setDescription(t('The time that the node was created.')) + ->setLabel(nt('Authored on')) + ->setDescription(nt('The time that the node was created.')) ->setRevisionable(TRUE) ->setTranslatable(TRUE) ->setDisplayOptions('view', array( @@ -419,14 +419,14 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ->setDisplayConfigurable('form', TRUE); $fields['changed'] = BaseFieldDefinition::create('changed') - ->setLabel(t('Changed')) - ->setDescription(t('The time that the node was last edited.')) + ->setLabel(nt('Changed')) + ->setDescription(nt('The time that the node was last edited.')) ->setRevisionable(TRUE) ->setTranslatable(TRUE); $fields['promote'] = BaseFieldDefinition::create('boolean') - ->setLabel(t('Promote')) - ->setDescription(t('A boolean indicating whether the node should be displayed on the front page.')) + ->setLabel(nt('Promote')) + ->setDescription(nt('A boolean indicating whether the node should be displayed on the front page.')) ->setRevisionable(TRUE) ->setTranslatable(TRUE) ->setDefaultValue(TRUE) @@ -440,8 +440,8 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ->setDisplayConfigurable('form', TRUE); $fields['sticky'] = BaseFieldDefinition::create('boolean') - ->setLabel(t('Sticky')) - ->setDescription(t('A boolean indicating whether the node should be displayed at the top of lists in which it appears.')) + ->setLabelnt(nt('Sticky')) + ->setDescription(nt('A boolean indicating whether the node should be displayed at the top of lists in which it appears.')) ->setRevisionable(TRUE) ->setTranslatable(TRUE) ->setDisplayOptions('form', array( @@ -454,21 +454,21 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ->setDisplayConfigurable('form', TRUE); $fields['revision_timestamp'] = BaseFieldDefinition::create('created') - ->setLabel(t('Revision timestamp')) - ->setDescription(t('The time that the current revision was created.')) + ->setLabel(nt('Revision timestamp')) + ->setDescription(nt('The time that the current revision was created.')) ->setQueryable(FALSE) ->setRevisionable(TRUE); $fields['revision_uid'] = BaseFieldDefinition::create('entity_reference') - ->setLabel(t('Revision user ID')) - ->setDescription(t('The user ID of the author of the current revision.')) + ->setLabel(nt('Revision user ID')) + ->setDescription(nt('The user ID of the author of the current revision.')) ->setSetting('target_type', 'user') ->setQueryable(FALSE) ->setRevisionable(TRUE); $fields['revision_log'] = BaseFieldDefinition::create('string_long') - ->setLabel(t('Revision log message')) - ->setDescription(t('Briefly describe the changes you have made.')) + ->setLabel(nt('Revision log message')) + ->setDescription(nt('Briefly describe the changes you have made.')) ->setRevisionable(TRUE) ->setTranslatable(TRUE) ->setDisplayOptions('form', array( diff --git a/core/modules/options/src/Plugin/Field/FieldType/ListFloatItem.php b/core/modules/options/src/Plugin/Field/FieldType/ListFloatItem.php index 6fa8fbe..f6d12ca 100644 --- a/core/modules/options/src/Plugin/Field/FieldType/ListFloatItem.php +++ b/core/modules/options/src/Plugin/Field/FieldType/ListFloatItem.php @@ -28,7 +28,7 @@ class ListFloatItem extends ListItemBase { */ public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) { $properties['value'] = DataDefinition::create('float') - ->setLabel(t('Float value')); + ->setLabel(nt('Float value')); return $properties; } diff --git a/core/modules/options/src/Plugin/Field/FieldType/ListIntegerItem.php b/core/modules/options/src/Plugin/Field/FieldType/ListIntegerItem.php index 8a0b297..8cc7f90 100644 --- a/core/modules/options/src/Plugin/Field/FieldType/ListIntegerItem.php +++ b/core/modules/options/src/Plugin/Field/FieldType/ListIntegerItem.php @@ -28,7 +28,7 @@ class ListIntegerItem extends ListItemBase { */ public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) { $properties['value'] = DataDefinition::create('integer') - ->setLabel(t('Integer value')); + ->setLabel(nt('Integer value')); return $properties; } diff --git a/core/modules/options/src/Plugin/Field/FieldType/ListStringItem.php b/core/modules/options/src/Plugin/Field/FieldType/ListStringItem.php index d74049a..d8c4780 100644 --- a/core/modules/options/src/Plugin/Field/FieldType/ListStringItem.php +++ b/core/modules/options/src/Plugin/Field/FieldType/ListStringItem.php @@ -29,7 +29,7 @@ class ListStringItem extends ListItemBase { */ public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) { $properties['value'] = DataDefinition::create('string') - ->setLabel(t('Text value')) + ->setLabel(nt('Text value')) ->addConstraint('Length', array('max' => 255)); return $properties; diff --git a/core/modules/path/path.module b/core/modules/path/path.module index 85fe106..fcc3dd3 100644 --- a/core/modules/path/path.module +++ b/core/modules/path/path.module @@ -65,7 +65,7 @@ function path_form_node_form_alter(&$form, FormStateInterface $form_state) { function path_entity_base_field_info(EntityTypeInterface $entity_type) { if ($entity_type->id() === 'taxonomy_term' || $entity_type->id() === 'node') { $fields['path'] = BaseFieldDefinition::create('path') - ->setLabel(t('URL alias')) + ->setLabel(nt('URL alias')) ->setTranslatable(TRUE) ->setDisplayOptions('form', array( 'type' => 'path', diff --git a/core/modules/path/src/Plugin/Field/FieldType/PathItem.php b/core/modules/path/src/Plugin/Field/FieldType/PathItem.php index cff3fa6..040bf0f 100644 --- a/core/modules/path/src/Plugin/Field/FieldType/PathItem.php +++ b/core/modules/path/src/Plugin/Field/FieldType/PathItem.php @@ -32,9 +32,9 @@ class PathItem extends FieldItemBase { */ public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) { $properties['alias'] = DataDefinition::create('string') - ->setLabel(t('Path alias')); + ->setLabel(nt('Path alias')); $properties['pid'] = DataDefinition::create('string') - ->setLabel(t('Path id')); + ->setLabel(nt('Path id')); return $properties; } diff --git a/core/modules/shortcut/src/Entity/Shortcut.php b/core/modules/shortcut/src/Entity/Shortcut.php index 770406a..f812cfd 100644 --- a/core/modules/shortcut/src/Entity/Shortcut.php +++ b/core/modules/shortcut/src/Entity/Shortcut.php @@ -169,25 +169,25 @@ public function postSave(EntityStorageInterface $storage, $update = TRUE) { */ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { $fields['id'] = BaseFieldDefinition::create('integer') - ->setLabel(t('ID')) - ->setDescription(t('The ID of the shortcut.')) + ->setLabel(nt('ID')) + ->setDescription(nt('The ID of the shortcut.')) ->setReadOnly(TRUE) ->setSetting('unsigned', TRUE); $fields['uuid'] = BaseFieldDefinition::create('uuid') - ->setLabel(t('UUID')) - ->setDescription(t('The UUID of the shortcut.')) + ->setLabel(nt('UUID')) + ->setDescription(nt('The UUID of the shortcut.')) ->setReadOnly(TRUE); $fields['shortcut_set'] = BaseFieldDefinition::create('entity_reference') - ->setLabel(t('Shortcut set')) - ->setDescription(t('The bundle of the shortcut.')) + ->setLabel(nt('Shortcut set')) + ->setDescription(nt('The bundle of the shortcut.')) ->setSetting('target_type', 'shortcut_set') ->setRequired(TRUE); $fields['title'] = BaseFieldDefinition::create('string') - ->setLabel(t('Name')) - ->setDescription(t('The name of the shortcut.')) + ->setLabel(nt('Name')) + ->setDescription(nt('The name of the shortcut.')) ->setRequired(TRUE) ->setTranslatable(TRUE) ->setDefaultValue('') @@ -201,24 +201,24 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { )); $fields['weight'] = BaseFieldDefinition::create('integer') - ->setLabel(t('Weight')) - ->setDescription(t('Weight among shortcuts in the same shortcut set.')); + ->setLabel(nt('Weight')) + ->setDescription(nt('Weight among shortcuts in the same shortcut set.')); $fields['route_name'] = BaseFieldDefinition::create('string') - ->setLabel(t('Route name')) - ->setDescription(t('The machine name of a defined Route this shortcut represents.')); + ->setLabel(nt('Route name')) + ->setDescription(nt('The machine name of a defined Route this shortcut represents.')); $fields['route_parameters'] = BaseFieldDefinition::create('map') - ->setLabel(t('Route parameters')) - ->setDescription(t('A serialized array of route parameters of this shortcut.')); + ->setLabel(nt('Route parameters')) + ->setDescription(nt('A serialized array of route parameters of this shortcut.')); $fields['langcode'] = BaseFieldDefinition::create('language') - ->setLabel(t('Language code')) - ->setDescription(t('The language code of the shortcut.')); + ->setLabel(nt('Language code')) + ->setDescription(nt('The language code of the shortcut.')); $fields['path'] = BaseFieldDefinition::create('string') - ->setLabel(t('Path')) - ->setDescription(t('The computed shortcut path.')) + ->setLabel(nt('Path')) + ->setDescription(nt('The computed shortcut path.')) ->setComputed(TRUE) ->setCustomStorage(TRUE); diff --git a/core/modules/shortcut/src/ShortcutPathItem.php b/core/modules/shortcut/src/ShortcutPathItem.php index 8ad82d3..c386267 100644 --- a/core/modules/shortcut/src/ShortcutPathItem.php +++ b/core/modules/shortcut/src/ShortcutPathItem.php @@ -21,7 +21,7 @@ class ShortcutPathItem extends StringItem { */ public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) { $properties['value'] = DataDefinition::create('string') - ->setLabel(t('String value')) + ->setLabel(nt('String value')) ->setComputed(TRUE) ->setClass('\Drupal\shortcut\ShortcutPathValue'); return $properties; diff --git a/core/modules/system/entity.api.php b/core/modules/system/entity.api.php index 189e8a2..f705c0e 100644 --- a/core/modules/system/entity.api.php +++ b/core/modules/system/entity.api.php @@ -1640,8 +1640,8 @@ function hook_entity_base_field_info(\Drupal\Core\Entity\EntityTypeInterface $en if ($entity_type->id() == 'node') { $fields = array(); $fields['mymodule_text'] = BaseFieldDefinition::create('string') - ->setLabel(t('The text')) - ->setDescription(t('A text property added by mymodule.')) + ->setLabel(nt('The text')) + ->setDescription(nt('A text property added by mymodule.')) ->setComputed(TRUE) ->setClass('\Drupal\mymodule\EntityComputedText'); @@ -1704,7 +1704,7 @@ function hook_entity_bundle_field_info(\Drupal\Core\Entity\EntityTypeInterface $ if ($entity_type->id() == 'node' && $bundle == 'article') { $fields = array(); $fields['mymodule_text_more'] = BaseFieldDefinition::create('string') - ->setLabel(t('More text')) + ->setLabel(nt('More text')) ->setComputed(TRUE) ->setClass('\Drupal\mymodule\EntityComputedMoreText'); return $fields; diff --git a/core/modules/system/src/Tests/Entity/EntityDefinitionUpdateTest.php b/core/modules/system/src/Tests/Entity/EntityDefinitionUpdateTest.php index 96c7583..2cea48a 100644 --- a/core/modules/system/src/Tests/Entity/EntityDefinitionUpdateTest.php +++ b/core/modules/system/src/Tests/Entity/EntityDefinitionUpdateTest.php @@ -498,7 +498,7 @@ protected function updateEntityTypeToRevisionable() { protected function addBaseField($type = 'string') { $definitions['new_base_field'] = BaseFieldDefinition::create($type) ->setName('new_base_field') - ->setLabel(t('A new base field')); + ->setLabel(nt('A new base field')); $this->state->set('entity_test_update.additional_base_field_definitions', $definitions); $this->entityManager->clearCachedDefinitions(); } @@ -543,7 +543,7 @@ protected function removeBaseFieldIndex() { protected function addBundleField($type = 'string') { $definitions['new_bundle_field'] = FieldStorageDefinition::create($type) ->setName('new_bundle_field') - ->setLabel(t('A new bundle field')) + ->setLabel(nt('A new bundle field')) ->setTargetEntityTypeId('entity_test_update'); $this->state->set('entity_test_update.additional_field_storage_definitions', $definitions); $this->state->set('entity_test_update.additional_bundle_field_definitions.test_bundle', $definitions); diff --git a/core/modules/system/src/Tests/Entity/EntityFieldTest.php b/core/modules/system/src/Tests/Entity/EntityFieldTest.php index 41dbb44..255d33e 100644 --- a/core/modules/system/src/Tests/Entity/EntityFieldTest.php +++ b/core/modules/system/src/Tests/Entity/EntityFieldTest.php @@ -625,7 +625,7 @@ public function testEntityConstraintValidation() { $entity->save(); // Create a reference field item and let it reference the entity. $definition = BaseFieldDefinition::create('entity_reference') - ->setLabel('Test entity') + ->setLabel(nt('Test entity')) ->setSetting('target_type', 'entity_test'); $reference_field = \Drupal::typedDataManager()->create($definition); $reference = $reference_field->first()->get('entity'); @@ -650,7 +650,7 @@ public function testEntityConstraintValidation() { NodeType::create(array('type' => 'article')) ->save(); $definition = BaseFieldDefinition::create('entity_reference') - ->setLabel('Test entity') + ->setLabel(nt('Test entity')) ->setSettings(array( 'target_type' => 'node', 'target_bundle' => 'article', diff --git a/core/modules/system/tests/modules/entity_schema_test/entity_schema_test.module b/core/modules/system/tests/modules/entity_schema_test/entity_schema_test.module index ab1d71b..0a74359 100644 --- a/core/modules/system/tests/modules/entity_schema_test/entity_schema_test.module +++ b/core/modules/system/tests/modules/entity_schema_test/entity_schema_test.module @@ -31,7 +31,7 @@ function entity_schema_test_entity_base_field_info(EntityTypeInterface $entity_t if ($entity_type->id() == 'entity_test') { $definitions['custom_base_field'] = BaseFieldDefinition::create('string') ->setName('custom_base_field') - ->setLabel(t('A custom base field')); + ->setLabel(nt('A custom base field')); if (\Drupal::state()->get('entity_schema_update')) { $definitions += EntityTestMulRev::baseFieldDefinitions($entity_type); } @@ -46,7 +46,7 @@ function entity_schema_test_entity_field_storage_info(EntityTypeInterface $entit if ($entity_type->id() == 'entity_test') { $definitions['custom_bundle_field'] = FieldStorageDefinition::create('string') ->setName('custom_bundle_field') - ->setLabel(t('A custom bundle field')) + ->setLabel(nt('A custom bundle field')) ->setTargetEntityTypeId($entity_type->id()); return $definitions; } diff --git a/core/modules/system/tests/modules/entity_test/src/Entity/EntityTest.php b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTest.php index 9200270..a9ab425 100644 --- a/core/modules/system/tests/modules/entity_test/src/Entity/EntityTest.php +++ b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTest.php @@ -64,23 +64,23 @@ public static function preCreate(EntityStorageInterface $storage, array &$values */ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { $fields['id'] = BaseFieldDefinition::create('integer') - ->setLabel(t('ID')) - ->setDescription(t('The ID of the test entity.')) + ->setLabel(nt('ID')) + ->setDescription(nt('The ID of the test entity.')) ->setReadOnly(TRUE) ->setSetting('unsigned', TRUE); $fields['uuid'] = BaseFieldDefinition::create('uuid') - ->setLabel(t('UUID')) - ->setDescription(t('The UUID of the test entity.')) + ->setLabel(nt('UUID')) + ->setDescription(nt('The UUID of the test entity.')) ->setReadOnly(TRUE); $fields['langcode'] = BaseFieldDefinition::create('language') - ->setLabel(t('Language code')) - ->setDescription(t('The language code of the test entity.')); + ->setLabel(nt('Language code')) + ->setDescription(nt('The language code of the test entity.')); $fields['name'] = BaseFieldDefinition::create('string') - ->setLabel(t('Name')) - ->setDescription(t('The name of the test entity.')) + ->setLabel(nt('Name')) + ->setDescription(nt('The name of the test entity.')) ->setTranslatable(TRUE) ->setSetting('max_length', 32) ->setDisplayOptions('view', array( @@ -95,13 +95,13 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { // @todo: Add allowed values validation. $fields['type'] = BaseFieldDefinition::create('string') - ->setLabel(t('Type')) - ->setDescription(t('The bundle of the test entity.')) + ->setLabel(nt('Type')) + ->setDescription(nt('The bundle of the test entity.')) ->setRequired(TRUE); $fields['user_id'] = BaseFieldDefinition::create('entity_reference') - ->setLabel(t('User ID')) - ->setDescription(t('The ID of the associated user.')) + ->setLabel(nt('User ID')) + ->setDescription(nt('The ID of the associated user.')) ->setSetting('target_type', 'user') ->setSetting('handler', 'default') // Default EntityTest entities to have the root user as the owner, to diff --git a/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestBaseFieldDisplay.php b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestBaseFieldDisplay.php index ed213e3..9f0ee81 100644 --- a/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestBaseFieldDisplay.php +++ b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestBaseFieldDisplay.php @@ -44,10 +44,10 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { $fields = parent::baseFieldDefinitions($entity_type); $fields['test_no_display'] = BaseFieldDefinition::create('text') - ->setLabel(t('Field with no display')); + ->setLabel(nt('Field with no display')); $fields['test_display_configurable'] = BaseFieldDefinition::create('text') - ->setLabel(t('Field with configurable display')) + ->setLabel(nt('Field with configurable display')) ->setDisplayOptions('view', array( 'type' => 'text_default', 'weight' => 10, @@ -60,7 +60,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ->setDisplayConfigurable('form', TRUE); $fields['test_display_non_configurable'] = BaseFieldDefinition::create('text') - ->setLabel(t('Field with non-configurable display')) + ->setLabel(nt('Field with non-configurable display')) ->setDisplayOptions('view', array( 'type' => 'text_default', 'weight' => 11, diff --git a/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestDefaultValue.php b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestDefaultValue.php index 1c1797f..b6a0bba 100644 --- a/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestDefaultValue.php +++ b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestDefaultValue.php @@ -33,7 +33,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { $fields = parent::baseFieldDefinitions($entity_type); $fields['description'] = BaseFieldDefinition::create('shape') - ->setLabel(t('Some custom description')) + ->setLabel(nt('Some custom description')) ->setDefaultValueCallback('entity_test_field_default_value'); return $fields; diff --git a/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestFieldOverride.php b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestFieldOverride.php index 7632125..11b7c74 100644 --- a/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestFieldOverride.php +++ b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestFieldOverride.php @@ -30,7 +30,7 @@ class EntityTestFieldOverride extends EntityTest { */ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { $fields = parent::baseFieldDefinitions($entity_type); - $fields['name']->setDescription('The default description.'); + $fields['name']->setDescription(nt('The default description.')); return $fields; } @@ -42,7 +42,7 @@ public static function bundleFieldDefinitions(EntityTypeInterface $entity_type, if ($bundle == 'some_test_bundle') { $fields['name'] = clone $base_field_definitions['name']; - $fields['name']->setDescription('Custom description.'); + $fields['name']->setDescription(nt('Custom description.')); } return $fields; } diff --git a/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestRev.php b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestRev.php index 3b40ed9..f05b457 100644 --- a/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestRev.php +++ b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestRev.php @@ -51,8 +51,8 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { $fields = parent::baseFieldDefinitions($entity_type); $fields['revision_id'] = BaseFieldDefinition::create('integer') - ->setLabel(t('Revision ID')) - ->setDescription(t('The version id of the test entity.')) + ->setLabel(nt('Revision ID')) + ->setDescription(nt('The version id of the test entity.')) ->setReadOnly(TRUE) ->setSetting('unsigned', TRUE); diff --git a/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestStringId.php b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestStringId.php index 9d74938..b64008c 100644 --- a/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestStringId.php +++ b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestStringId.php @@ -43,8 +43,8 @@ class EntityTestStringId extends EntityTest { public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { $fields = parent::baseFieldDefinitions($entity_type); $fields['id'] = BaseFieldDefinition::create('string') - ->setLabel(t('ID')) - ->setDescription(t('The ID of the test entity.')) + ->setLabel(nt('ID')) + ->setDescription(nt('The ID of the test entity.')) ->setReadOnly(TRUE); return $fields; } diff --git a/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/ShapeItem.php b/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/ShapeItem.php index 4dc8196..64b3314 100644 --- a/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/ShapeItem.php +++ b/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/ShapeItem.php @@ -36,10 +36,10 @@ public static function defaultStorageSettings() { */ public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) { $properties['shape'] = DataDefinition::create('string') - ->setLabel(t('Shape')); + ->setLabel(nt('Shape')); $properties['color'] = DataDefinition::create('string') - ->setLabel(t('Color')); + ->setLabel(nt('Color')); return $properties; } diff --git a/core/modules/taxonomy/src/Entity/Term.php b/core/modules/taxonomy/src/Entity/Term.php index caebc53..f88ce90 100644 --- a/core/modules/taxonomy/src/Entity/Term.php +++ b/core/modules/taxonomy/src/Entity/Term.php @@ -102,28 +102,28 @@ public function postSave(EntityStorageInterface $storage, $update = TRUE) { */ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { $fields['tid'] = BaseFieldDefinition::create('integer') - ->setLabel(t('Term ID')) - ->setDescription(t('The term ID.')) + ->setLabel(nt('Term ID')) + ->setDescription(nt('The term ID.')) ->setReadOnly(TRUE) ->setSetting('unsigned', TRUE); $fields['uuid'] = BaseFieldDefinition::create('uuid') - ->setLabel(t('UUID')) - ->setDescription(t('The term UUID.')) + ->setLabel(nt('UUID')) + ->setDescription(nt('The term UUID.')) ->setReadOnly(TRUE); $fields['vid'] = BaseFieldDefinition::create('entity_reference') - ->setLabel(t('Vocabulary')) - ->setDescription(t('The vocabulary to which the term is assigned.')) + ->setLabel(nt('Vocabulary')) + ->setDescription(nt('The vocabulary to which the term is assigned.')) ->setSetting('target_type', 'taxonomy_vocabulary'); $fields['langcode'] = BaseFieldDefinition::create('language') - ->setLabel(t('Language code')) - ->setDescription(t('The term language code.')); + ->setLabel(nt('Language code')) + ->setDescription(nt('The term language code.')); $fields['name'] = BaseFieldDefinition::create('string') - ->setLabel(t('Name')) - ->setDescription(t('The term name.')) + ->setLabel(nt('Name')) + ->setDescription(nt('The term name.')) ->setTranslatable(TRUE) ->setRequired(TRUE) ->setSetting('max_length', 255) @@ -139,8 +139,8 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ->setDisplayConfigurable('form', TRUE); $fields['description'] = BaseFieldDefinition::create('text_long') - ->setLabel(t('Description')) - ->setDescription(t('A description of the term.')) + ->setLabel(nt('Description')) + ->setDescription(nt('A description of the term.')) ->setTranslatable(TRUE) ->setDisplayOptions('view', array( 'label' => 'hidden', @@ -155,20 +155,20 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ->setDisplayConfigurable('form', TRUE); $fields['weight'] = BaseFieldDefinition::create('integer') - ->setLabel(t('Weight')) - ->setDescription(t('The weight of this term in relation to other terms.')) + ->setLabel(nt('Weight')) + ->setDescription(nt('The weight of this term in relation to other terms.')) ->setDefaultValue(0); $fields['parent'] = BaseFieldDefinition::create('entity_reference') - ->setLabel(t('Term Parents')) - ->setDescription(t('The parents of this term.')) + ->setLabel(nt('Term Parents')) + ->setDescription(nt('The parents of this term.')) ->setSetting('target_type', 'taxonomy_term') ->setCardinality(BaseFieldDefinition::CARDINALITY_UNLIMITED) ->setCustomStorage(TRUE); $fields['changed'] = BaseFieldDefinition::create('changed') - ->setLabel(t('Changed')) - ->setDescription(t('The time that the term was last edited.')); + ->setLabel(nt('Changed')) + ->setDescription(nt('The time that the term was last edited.')); return $fields; } diff --git a/core/modules/telephone/src/Plugin/Field/FieldType/TelephoneItem.php b/core/modules/telephone/src/Plugin/Field/FieldType/TelephoneItem.php index 5e59974..3b76cdc 100644 --- a/core/modules/telephone/src/Plugin/Field/FieldType/TelephoneItem.php +++ b/core/modules/telephone/src/Plugin/Field/FieldType/TelephoneItem.php @@ -45,7 +45,7 @@ public static function schema(FieldStorageDefinitionInterface $field_definition) */ public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) { $properties['value'] = DataDefinition::create('string') - ->setLabel(t('Telephone number')); + ->setLabel(nt('Telephone number')); return $properties; } diff --git a/core/modules/text/src/Plugin/Field/FieldType/TextItemBase.php b/core/modules/text/src/Plugin/Field/FieldType/TextItemBase.php index e08f951..25cbe09 100644 --- a/core/modules/text/src/Plugin/Field/FieldType/TextItemBase.php +++ b/core/modules/text/src/Plugin/Field/FieldType/TextItemBase.php @@ -23,14 +23,14 @@ */ public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) { $properties['value'] = DataDefinition::create('string') - ->setLabel(t('Text')); + ->setLabel(nt('Text')); $properties['format'] = DataDefinition::create('filter_format') - ->setLabel(t('Text format')); + ->setLabel(nt('Text format')); $properties['processed'] = DataDefinition::create('string') - ->setLabel(t('Processed text')) - ->setDescription(t('The text with the text format applied.')) + ->setLabel(nt('Processed text')) + ->setDescription(nt('The text with the text format applied.')) ->setComputed(TRUE) ->setClass('\Drupal\text\TextProcessed') ->setSetting('text source', 'value'); diff --git a/core/modules/text/src/Plugin/Field/FieldType/TextWithSummaryItem.php b/core/modules/text/src/Plugin/Field/FieldType/TextWithSummaryItem.php index e0ba0c8..801c25e 100644 --- a/core/modules/text/src/Plugin/Field/FieldType/TextWithSummaryItem.php +++ b/core/modules/text/src/Plugin/Field/FieldType/TextWithSummaryItem.php @@ -40,11 +40,11 @@ public static function propertyDefinitions(FieldStorageDefinitionInterface $fiel $properties = parent::propertyDefinitions($field_definition); $properties['summary'] = DataDefinition::create('string') - ->setLabel(t('Summary')); + ->setLabel(nt('Summary')); $properties['summary_processed'] = DataDefinition::create('string') - ->setLabel(t('Processed summary')) - ->setDescription(t('The summary text with the text format applied.')) + ->setLabel(nt('Processed summary')) + ->setDescription(nt('The summary text with the text format applied.')) ->setComputed(TRUE) ->setClass('\Drupal\text\TextProcessed') ->setSetting('text source', 'summary'); diff --git a/core/modules/user/src/Entity/User.php b/core/modules/user/src/Entity/User.php index 629ce9c..032ff3f 100644 --- a/core/modules/user/src/Entity/User.php +++ b/core/modules/user/src/Entity/User.php @@ -441,34 +441,34 @@ public function getChangedTime() { */ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { $fields['uid'] = BaseFieldDefinition::create('integer') - ->setLabel(t('User ID')) - ->setDescription(t('The user ID.')) + ->setLabel(nt('User ID')) + ->setDescription(nt('The user ID.')) ->setReadOnly(TRUE) ->setSetting('unsigned', TRUE); $fields['uuid'] = BaseFieldDefinition::create('uuid') - ->setLabel(t('UUID')) - ->setDescription(t('The user UUID.')) + ->setLabel(nt('UUID')) + ->setDescription(nt('The user UUID.')) ->setReadOnly(TRUE); $fields['langcode'] = BaseFieldDefinition::create('language') - ->setLabel(t('Language code')) - ->setDescription(t('The user language code.')); + ->setLabel(nt('Language code')) + ->setDescription(nt('The user language code.')); $fields['preferred_langcode'] = BaseFieldDefinition::create('language') - ->setLabel(t('Preferred language code')) - ->setDescription(t("The user's preferred language code for receiving emails and viewing the site.")); + ->setLabel(nt('Preferred language code')) + ->setDescription(nt("The user's preferred language code for receiving emails and viewing the site.")); $fields['preferred_admin_langcode'] = BaseFieldDefinition::create('language') - ->setLabel(t('Preferred admin language code')) - ->setDescription(t("The user's preferred language code for viewing administration pages.")) + ->setLabel(nt('Preferred admin language code')) + ->setDescription(nt("The user's preferred language code for viewing administration pages.")) ->setDefaultValue(''); // The name should not vary per language. The username is the visual // identifier for a user and needs to be consistent in all languages. $fields['name'] = BaseFieldDefinition::create('string') - ->setLabel(t('Name')) - ->setDescription(t('The name of this user.')) + ->setLabel(nt('Name')) + ->setDescription(nt('The name of this user.')) ->setDefaultValue('') ->setConstraints(array( // No Length constraint here because the UserName constraint also covers @@ -478,61 +478,61 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { )); $fields['pass'] = BaseFieldDefinition::create('string') - ->setLabel(t('Password')) - ->setDescription(t('The password of this user (hashed).')); + ->setLabel(nt('Password')) + ->setDescription(nt('The password of this user (hashed).')); $fields['mail'] = BaseFieldDefinition::create('email') - ->setLabel(t('Email')) - ->setDescription(t('The email of this user.')) + ->setLabel(nt('Email')) + ->setDescription(nt('The email of this user.')) ->setDefaultValue('') ->setConstraints(array('UserMailUnique' => array())); // @todo Convert to a text field in https://drupal.org/node/1548204. $fields['signature'] = BaseFieldDefinition::create('string') - ->setLabel(t('Signature')) - ->setDescription(t('The signature of this user.')) + ->setLabel(nt('Signature')) + ->setDescription(nt('The signature of this user.')) ->setTranslatable(TRUE); $fields['signature_format'] = BaseFieldDefinition::create('string') - ->setLabel(t('Signature format')) - ->setDescription(t('The signature format of this user.')); + ->setLabel(nt('Signature format')) + ->setDescription(nt('The signature format of this user.')); $fields['timezone'] = BaseFieldDefinition::create('string') - ->setLabel(t('Timezone')) - ->setDescription(t('The timezone of this user.')) + ->setLabel(nt('Timezone')) + ->setDescription(nt('The timezone of this user.')) ->setSetting('max_length', 32); $fields['status'] = BaseFieldDefinition::create('boolean') - ->setLabel(t('User status')) - ->setDescription(t('Whether the user is active or blocked.')) + ->setLabel(nt('User status')) + ->setDescription(nt('Whether the user is active or blocked.')) ->setDefaultValue(FALSE); $fields['created'] = BaseFieldDefinition::create('created') - ->setLabel(t('Created')) - ->setDescription(t('The time that the user was created.')); + ->setLabel(nt('Created')) + ->setDescription(nt('The time that the user was created.')); $fields['changed'] = BaseFieldDefinition::create('changed') - ->setLabel(t('Changed')) - ->setDescription(t('The time that the user was last edited.')); + ->setLabel(nt('Changed')) + ->setDescription(nt('The time that the user was last edited.')); $fields['access'] = BaseFieldDefinition::create('timestamp') - ->setLabel(t('Last access')) - ->setDescription(t('The time that the user last accessed the site.')) + ->setLabel(nt('Last access')) + ->setDescription(nt('The time that the user last accessed the site.')) ->setDefaultValue(0); $fields['login'] = BaseFieldDefinition::create('timestamp') - ->setLabel(t('Last login')) - ->setDescription(t('The time that the user last logged in.')) + ->setLabel(nt('Last login')) + ->setDescription(nt('The time that the user last logged in.')) ->setDefaultValue(0); $fields['init'] = BaseFieldDefinition::create('email') - ->setLabel(t('Initial email')) - ->setDescription(t('The email address used for initial account creation.')) + ->setLabel(nt('Initial email')) + ->setDescription(nt('The email address used for initial account creation.')) ->setDefaultValue(''); $fields['roles'] = BaseFieldDefinition::create('entity_reference') - ->setLabel(t('Roles')) + ->setLabel(nt('Roles')) ->setCardinality(BaseFieldDefinition::CARDINALITY_UNLIMITED) - ->setDescription(t('The roles the user has.')) + ->setDescription(nt('The roles the user has.')) ->setSetting('target_type', 'user_role'); return $fields; diff --git a/core/modules/views/tests/src/Unit/EntityViewsDataTest.php b/core/modules/views/tests/src/Unit/EntityViewsDataTest.php index 476a199..3133c1e 100644 --- a/core/modules/views/tests/src/Unit/EntityViewsDataTest.php +++ b/core/modules/views/tests/src/Unit/EntityViewsDataTest.php @@ -109,6 +109,7 @@ protected function setUp() { $container = new ContainerBuilder(); $container->set('plugin.manager.field.field_type', $field_type_manager); $container->set('entity.manager', $this->entityManager); + $container->set('string_translation', $this->getStringTranslationStub()); \Drupal::setContainer($container); } @@ -125,8 +126,8 @@ protected function setupBaseFields(array $base_fields) { // Add a description field to the fields supplied by the EntityTest // classes. This example comes from the taxonomy Term entity. $base_fields['description'] = BaseFieldDefinition::create('text_long') - ->setLabel(t('Description')) - ->setDescription(t('A description of the term.')) + ->setLabel(nt('Description')) + ->setDescription(nt('A description of the term.')) ->setTranslatable(TRUE) ->setDisplayOptions('view', array( 'label' => 'hidden', @@ -142,8 +143,8 @@ protected function setupBaseFields(array $base_fields) { // Add a URL field; this example is from the Comment entity. $base_fields['homepage'] = BaseFieldDefinition::create('uri') - ->setLabel(t('Homepage')) - ->setDescription(t("The comment author's home page address.")) + ->setLabel(nt('Homepage')) + ->setDescription(nt("The comment author's home page address.")) ->setTranslatable(TRUE) ->setSetting('max_length', 255); @@ -372,7 +373,7 @@ public function testDataTableFields() { ; $base_field_definitions = $this->setupBaseFields(EntityTestMul::baseFieldDefinitions($this->baseEntityType)); $base_field_definitions['type'] = BaseFieldDefinition::create('entity_reference') - ->setLabel('entity test type') + ->setLabel(nt('entity test type')) ->setSettings(array('target_type' => 'entity_test_bundle')) ->setTranslatable(TRUE); $base_field_definitions = $this->setupBaseFields($base_field_definitions); diff --git a/core/tests/Drupal/Tests/Core/Entity/BaseFieldDefinitionTest.php b/core/tests/Drupal/Tests/Core/Entity/BaseFieldDefinitionTest.php index 2f1235b..ff490a6 100644 --- a/core/tests/Drupal/Tests/Core/Entity/BaseFieldDefinitionTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/BaseFieldDefinitionTest.php @@ -71,6 +71,7 @@ protected function setUp() { $container = new ContainerBuilder(); $container->set('plugin.manager.field.field_type', $field_type_manager); + $container->set('string_translation', $this->getStringTranslationStub()); \Drupal::setContainer($container); }