diff -u b/modules/paragraphs_collection_test/paragraphs_collection_test.paragraphs.style_group.yml b/modules/paragraphs_collection_test/paragraphs_collection_test.paragraphs.style_group.yml --- b/modules/paragraphs_collection_test/paragraphs_collection_test.paragraphs.style_group.yml +++ b/modules/paragraphs_collection_test/paragraphs_collection_test.paragraphs.style_group.yml @@ -2,7 +2,7 @@ label: 'Regular Test Group' bold_test_group: label: 'Bold Test Group' - context_label: 'Bold CONTEXT' + widget_label: 'Bold CONTEXT' italic_test_group: label: 'Italic Test Group' underline_test_group: diff -u b/src/Plugin/paragraphs/Behavior/ParagraphsStylePlugin.php b/src/Plugin/paragraphs/Behavior/ParagraphsStylePlugin.php --- b/src/Plugin/paragraphs/Behavior/ParagraphsStylePlugin.php +++ b/src/Plugin/paragraphs/Behavior/ParagraphsStylePlugin.php @@ -115,14 +115,9 @@ // - There is more than one style option // - There is exactly one style option and no style group default style. if (($disabled && !$paragraph->isNew()) || count($style_options) > 1 || (count($style_options) === 1 && !$group_default)) { - $title = $this->t('%group style', ['%group' => $this->yamlStyleDiscovery->getGroupLabel($group_id)]); - // If there is a context label use it without adding a "Style" suffix. - if ($group_label = $this->yamlStyleDiscovery->getGroupContextLabel($group_id)) { - $title = $this->t('%group', ['%group' => $group_label]); - } $form['style_wrapper']['styles'][$group_id] = [ '#type' => 'select', - '#title' => $title, + '#title' => $this->yamlStyleDiscovery->getGroupWidgetLabel($group_id), '#options' => $style_options, '#default_value' => $default_style, '#attributes' => ['class' => ['paragraphs-style']], @@ -295,12 +290,8 @@ foreach ($styles as $group_id => $style) { // Check if the style set in the Paragraph is enabled in the collection. if (isset($style_options[$style]) && (!isset($this->configuration['groups'][$group_id]) || $style != $this->configuration['groups'][$group_id]['default'])) { - // If there is not a context label, use the group label instead. - if (!$group = $this->yamlStyleDiscovery->getGroupContextLabel($group_id)) { - $group = $this->yamlStyleDiscovery->getGroupLabel($group_id); - } $summary[] = $this->t('@group: @style', [ - '@group' => $group, + '@group' => $this->yamlStyleDiscovery->getGroupWidgetLabel($group_id), '@style' => $style_options[$style] ]); } diff -u b/src/StyleDiscovery.php b/src/StyleDiscovery.php --- b/src/StyleDiscovery.php +++ b/src/StyleDiscovery.php @@ -265,7 +265,7 @@ } $this->groupCollection[$group] = [ 'label' => $this->t($definition['label']), - 'context_label' => isset($definition['context_label']) ? $this->t($definition['context_label']) : NULL + 'widget_label' => isset($definition['widget_label']) ? $this->t($definition['widget_label']) : NULL ]; } } @@ -291,7 +291,7 @@ */ public function getGroupLabel($group_id) { $groups = $this->getStyleGroups(); - if (in_array($group_id, array_keys($groups))) { + if (isset($groups[$group_id])) { return $groups[$group_id]['label']; } return NULL; @@ -300,10 +300,18 @@ /** * {@inheritdoc} */ - public function getGroupContextLabel($group_id) { + public function getGroupWidgetLabel($group_id) { $groups = $this->getStyleGroups(); - if (in_array($group_id, array_keys($groups))) { - return $groups[$group_id]['context_label']; + if (isset($groups[$group_id])) { + // If the widget label is empty use the general label and add a "style + // suffix". + if ($widget_label = $groups[$group_id]['widget_label']) { + $label = $this->t('%group', ['%group' => $widget_label]); + } + else { + $label = $this->t('%group style', ['%group' => $this->getGroupLabel($group_id)]); + } + return $label; } return NULL; } diff -u b/src/StyleDiscoveryInterface.php b/src/StyleDiscoveryInterface.php --- b/src/StyleDiscoveryInterface.php +++ b/src/StyleDiscoveryInterface.php @@ -103,10 +103,10 @@ * @param string $group_id * The group id. * - * @return string + * @return \Drupal\Core\StringTranslation\TranslatableMarkup * The translatable group label. */ - public function getGroupContextLabel($group_id); + public function getGroupWidgetLabel($group_id); /** * Reset the cached definitions. diff -u b/style_group_translation_patterns.yml b/style_group_translation_patterns.yml --- b/style_group_translation_patterns.yml +++ b/style_group_translation_patterns.yml @@ -5 +5 @@ - - context_label + - widget_label