[Drupal 10.2] Using a translatable string as a category for field type is deprecated

Created on 29 February 2024, 4 months ago

Problem/Motivation

With Drupal 10.2, I found this deprecation message in logs:

Using a translatable string as a category for field type is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. See https://www.drupal.org/node/3364271 β†’

Steps to reproduce

Check the following file: src/Plugin/Field/FieldType/KeyValueItem.php

/**
 * Plugin implementation of the 'key_value' field type.
 *
 * @FieldType(
 *   id = "key_value",
 *   label = @Translation("Key / Value (plain)"),
 *   description = @Translation("This field stores key value pairs."),
 *   category = @Translation("Key / Value"),
 *   default_widget = "key_value_textfield",
 *   default_formatter = "key_value",
 *   column_groups = {
 *     "key" = {
 *       "label" = @Translation("Key"),
 *       "translatable" = TRUE,
 *     },
 *     "value" = {
 *       "label" = @Translation("Value"),
 *       "translatable" = TRUE,
 *     },
 *     "description" = {
 *       "label" = @Translation("Description"),
 *       "translatable" = TRUE,
 *     },
 *   },
 * )
 */

Check the following file: src/Plugin/Field/FieldType/KeyValueLongItem.php

/**
 * Plugin implementation of the 'key_value' field type.
 *
 * @FieldType(
 *   id = "key_value_long",
 *   label = @Translation("Key / Value (long)"),
 *   description = @Translation("This field stores key value pairs."),
 *   category = @Translation("Key / Value"),
 *   default_widget = "key_value_textarea",
 *   default_formatter = "key_value",
 *   column_groups = {
 *     "key" = {
 *       "label" = @Translation("Key"),
 *       "translatable" = TRUE,
 *     },
 *     "value" = {
 *       "label" = @Translation("Value"),
 *       "translatable" = TRUE,
 *     },
 *     "description" = {
 *       "label" = @Translation("Description"),
 *       "translatable" = TRUE,
 *     },
 *   },
 * )
 */

Proposed resolution

Fix it according to https://www.drupal.org/node/3375748 β†’

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡¦πŸ‡ΊAustralia paulabg

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.69.0 2024