From a808672fda415647004ea997cc82613c956532bd Mon Sep 17 00:00:00 2001 From: Willow Gillingham Date: Thu, 1 Dec 2022 15:54:11 -0500 Subject: [PATCH 1/2] wrap the relator type with t() function --- src/Plugin/Field/FieldFormatter/TypedRelationFormatter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Plugin/Field/FieldFormatter/TypedRelationFormatter.php b/src/Plugin/Field/FieldFormatter/TypedRelationFormatter.php index 2ebce91..dc645ee 100644 --- a/src/Plugin/Field/FieldFormatter/TypedRelationFormatter.php +++ b/src/Plugin/Field/FieldFormatter/TypedRelationFormatter.php @@ -29,7 +29,7 @@ public function viewElements(FieldItemListInterface $items, $langcode) { $rel_types = $item->getRelTypes(); $rel_type = isset($rel_types[$item->rel_type]) ? $rel_types[$item->rel_type] : $item->rel_type; if (!empty($rel_type)) { - $elements[$delta]['#prefix'] = $rel_type . ': '; + $elements[$delta]['#prefix'] = $this->t($rel_type) . ': '; } } From f576fe447a92e3860c0380112d831e222a16ce7d Mon Sep 17 00:00:00 2001 From: Rosie Le Faive Date: Wed, 25 Jan 2023 14:13:47 -0400 Subject: [PATCH 2/2] Switch to use schema to define rel_type as translatable. (#93) --- config/schema/controlled_access_terms.schema.yml | 2 +- src/Plugin/Field/FieldFormatter/TypedRelationFormatter.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/schema/controlled_access_terms.schema.yml b/config/schema/controlled_access_terms.schema.yml index 39b8282..727e63c 100644 --- a/config/schema/controlled_access_terms.schema.yml +++ b/config/schema/controlled_access_terms.schema.yml @@ -114,7 +114,7 @@ field.field_settings.typed_relation: rel_types: type: sequence sequence: - type: string + type: label field.storage_settings.edtf: type: field.storage_settings.string diff --git a/src/Plugin/Field/FieldFormatter/TypedRelationFormatter.php b/src/Plugin/Field/FieldFormatter/TypedRelationFormatter.php index dc645ee..2ebce91 100644 --- a/src/Plugin/Field/FieldFormatter/TypedRelationFormatter.php +++ b/src/Plugin/Field/FieldFormatter/TypedRelationFormatter.php @@ -29,7 +29,7 @@ public function viewElements(FieldItemListInterface $items, $langcode) { $rel_types = $item->getRelTypes(); $rel_type = isset($rel_types[$item->rel_type]) ? $rel_types[$item->rel_type] : $item->rel_type; if (!empty($rel_type)) { - $elements[$delta]['#prefix'] = $this->t($rel_type) . ': '; + $elements[$delta]['#prefix'] = $rel_type . ': '; } }