diff --git a/core/config/schema/core.entity.schema.yml b/core/config/schema/core.entity.schema.yml
index 406118a..6a4bc1a 100644
--- a/core/config/schema/core.entity.schema.yml
+++ b/core/config/schema/core.entity.schema.yml
@@ -356,7 +356,7 @@ field.formatter.settings.entity_reference_label:
type: boolean
label: 'Link label to the referenced entity'
-bundle:
+bundle_config_entity:
type: config_entity
label: 'Bundle'
mapping:
@@ -370,5 +370,5 @@ bundle:
type: sequence
label: 'Count label'
sequence:
- type: string
+ type: label
label: 'Plural variant'
diff --git a/core/modules/node/config/schema/node.schema.yml b/core/modules/node/config/schema/node.schema.yml
index 4cc1b1f..936f616 100644
--- a/core/modules/node/config/schema/node.schema.yml
+++ b/core/modules/node/config/schema/node.schema.yml
@@ -9,7 +9,7 @@ node.settings:
label: 'Use admin theme when editing or creating content'
node.type.*:
- type: bundle
+ type: bundle_config_entity
label: 'Content type'
mapping:
name:
diff --git a/core/modules/node/src/NodeTypeForm.php b/core/modules/node/src/NodeTypeForm.php
index 0d92b92..6d160ab 100644
--- a/core/modules/node/src/NodeTypeForm.php
+++ b/core/modules/node/src/NodeTypeForm.php
@@ -46,8 +46,7 @@ public static function create(ContainerInterface $container) {
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
- /** @var \Drupal\node\NodeTypeInterface $type */
- $type = $this->getEntity();
+ $type = $this->entity;
if ($this->operation == 'add') {
$form['#title'] = $this->t('Add content type');
$fields = $this->entityManager->getBaseFieldDefinitions('node');
@@ -202,7 +201,7 @@ public function form(array $form, FormStateInterface $form_state) {
];
if (\Drupal::hasService('locale.plural.formula')) {
- $langcode = \Drupal::languageManager()->getCurrentLanguage()->getId();
+ $langcode = $type->language()->getId();
$plurals = \Drupal::service('locale.plural.formula')->getNumberOfPlurals($langcode);
}
else {
@@ -214,18 +213,18 @@ public function form(array $form, FormStateInterface $form_state) {
$form['display']['label_count'] = [
'#type' => 'fieldset',
'#title' => $this->t('Count labels'),
- '#description' => $this->t('Token @count is available.'),
+ '#description' => $this->t('Count labels are used to build a text representation of a certain number of @label_plural. Token @count is available and will be replaced with the number of @label_plural.', ['@label_plural' => $type->getPluralLabel()]),
'#tree' => TRUE,
];
for ($i = 0; $i < $plurals; $i++) {
if ($i == 0) {
- $title = $this->t('Singular');
+ $title = $this->t('Singular form');
}
elseif ($plurals == 2 && $i == 1) {
- $title = $this->t('Plural');
+ $title = $this->t('Plural form');
}
else {
- $title = $this->t('Plural variant #@variant', ['@variant' => $i]);
+ $title = $this->formatPlural($i, 'First plural form', '@count. plural form');
}
if (isset($label_count[$i])) {
$default_value = $label_count[$i];
@@ -240,6 +239,7 @@ public function form(array $form, FormStateInterface $form_state) {
$form['display']['label_count'][$i] = [
'#type' => 'textfield',
'#title' => $title,
+ '#description' => $this->t('Text to use for this variant, @count will be replaced with the number of @label_plural.', ['@label_plural' => $type->getPluralLabel()]),
'#default_value' => $default_value,
];
}
diff --git a/core/modules/system/system.module b/core/modules/system/system.module
index b33e043..eab4173 100644
--- a/core/modules/system/system.module
+++ b/core/modules/system/system.module
@@ -1413,13 +1413,24 @@ function system_entity_type_build(array &$entity_types) {
* Implements hook_entity_type_alter().
*/
function system_entity_type_alter(array &$entity_types) {
+ /** @var Drupal\Core\Config\TypedConfigManagerInterface $typed_config_manager */
+ $typed_config_manager = \Drupal::service('config.typed');
+
/** @var \Drupal\Core\Entity\EntityTypeInterface[] $entity_types */
foreach ($entity_types as $entity_type_id => &$entity_type) {
+ // Automatically add label_singular, label_plural, label_count properties to
+ // config_export annotation list for bundle entity types that support label
+ // plural variants. The check is performed by inspecting the bundle entity
+ // type config schema.
if (is_subclass_of($entity_type->getClass(), ConfigEntityBundleInterface::class)) {
+ $name = "{$entity_type->getConfigPrefix()}.$entity_type_id";
+ $definition = $typed_config_manager->getDefinition($name);
$config_export = $entity_type->get('config_export');
- $config_export[] = 'label_singular';
- $config_export[] = 'label_plural';
- $config_export[] = 'label_count';
+ foreach (['label_singular', 'label_plural', 'label_count'] as $key) {
+ if (!empty($definition['mapping'][$key])) {
+ $config_export[] = $key;
+ }
+ }
$entity_type->set('config_export', $config_export);
}
}