In a form that extends ConfigFormBase, an element with a #config_target and no #title now gets the label from the config schema, passed through t().
In the same way, a form element with no #description gets its description from the schema.
A form element that sets its own #title or #description does not use the label or description from the config schema.
Example for the 'Max age' page cache setting before this change:
$form['caching']['page_cache_maximum_age'] = [
'#type' => 'select',
'#title' => $this->t('Browser and proxy cache maximum age'),
'#config_target' => 'system.performance:cache.page.max_age',
'#options' => $period,
'#description' => $this->t('This is used as the value for max-age in Cache-Control headers.'),
];
After this change, the schema can specify the label and description:
max_age:
type: integer
label: 'Browser and proxy cache maximum age'
description: 'This is used as the value for max-age in Cache-Control headers.'
And the form element can be updated to leave out #title and #description:
$form['caching']['page_cache_maximum_age'] = [
'#type' => 'select',
'#config_target' => 'system.performance:cache.page.max_age',
'#options' => $period,
];
A schema description is translated like a schema label: potx, which collects the strings localize.drupal.org translates, now extracts description from config/schema/*.yml as it already does for label.
This also adds a new method, TypedConfigManagerInterface::getDefinitionForKey($config_name, $key), which returns the data definition of one key in a configuration object's schema, like getDefinitionForKey('system.performance', 'cache.page.max_age'). Unlike creating typed config from the saved data, it reads only the schema, so it also works for a key with no saved value.
It returns NULL when the schema doesn't define the key. Classes that implement TypedConfigManagerInterface themselves, rather than extending TypedConfigManager, need to add the method.