Translate configuration values in custom webform handler I created a Custom Webform Handler, which uses the email and name data from the form input to subscribe the user to a newsletter service through the vendors API.
Ich created a configuration form with this handler, where I can input the API key and the mailing list of the newsletter service.
This all works well up until the point where I want to translate the webform to a different language. I need to have a different configuration for the mailing list in German than in English.
I checked the code of the handlers that come with the webform module, but I can't figure out, how to define, which configuration field values should be translated. I need to have the newsletter_list form element to be translated.
Can anyone help?
This is my shortened code
&lt;?php
/**
  * @file custom_webform_handler/src/Plugin/WebformHandler/NewsletterWebformHandler.php
  */
namespace Drupal\custom_webform_handler\Plugin\WebformHandler;

use Drupal\webform\Plugin\WebformHandlerBase;

// ...
/**
 * ´Newsletter Webform handler.
 *
 * @WebformHandler(
 *   id = &quot;newsletter&quot;,
 *   label = @Translation(&quot;Newsletter Subscription&quot;),
 *   category = @Translation(&quot;Subscription&quot;),
 *   description = @Translation(&quot;Subscribe to Newsletter&quot;),
 *   cardinality = \Drupal\webform\Plugin\WebformHandlerInterface::CARDINALITY_SINGLE,
 *   results = \Drupal\webform\Plugin\WebformHandlerInterface::RESULTS_IGNORED,
 *   submission = \Drupal\webform\Plugin\WebformHandlerInterface::SUBMISSION_REQUIRED,
 * )
 */

class NewsletterWebformHandler extends WebformHandlerBase
{
  /**
   * {@inheritdoc}
   */
  public function defaultConfiguration() {
    return [
      'newsletter_apikey' =&gt; '',
      'newsletter_list' =&gt; '',
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
    $form['newsletter'] = [
      '#type' =&gt; 'fieldset',
      '#title' =&gt; $this-&gt;t('Newsletter settings'),
    ];
    $form['newsletter']['newsletter_apikey'] = [
      '#type' =&gt; 'textfield',
      '#title' =&gt; $this-&gt;t('API key'),
      '#default_value' =&gt; $this-&gt;configuration['newsletter_apikey'],
      '#required' =&gt; TRUE,
    ];
    $form['newsletter']['newsletter_list'] = [
      '#type' =&gt; 'textfield',
      '#title' =&gt; $this-&gt;t('Mailing List'),
      '#default_value' =&gt; $this-&gt;configuration['newsletter_list'],
      '#required' =&gt; TRUE,
    ];
    
    return $this-&gt;setSettingsParents($form);

  }
  /**
   * {@inheritdoc}
   */
  public function submitConfigurationForm(array &amp;$form, FormStateInterface $form_state) {
    parent::submitConfigurationForm($form, $form_state);
    // ...
  }

// ...
}


I read that I need to have a schema for doing this, so I tried adding one, but it didn't change anything
# file custom_webform_handler/config/schema/custom_webform_handler.schema.yml
webform.handler.newsletter:
  type: mapping
  label: 'Newsletter'
  mapping:
    newsletter_list:
      label: 'Mailing List'
      type: string



Edit
To make it more clear:
I created a Handler that has this configuration form

The connection settings are the ones that need to be translated
When I go to the translation page of my webform, I can translate the Email-Handler settings, but not my custom Newsletter Subscription handler settings
I did provide the wrong type. It should be label and not string
webform.handler.newsletter2go:
  type: mapping
  label: 'Newsletter2go'
  mapping:
    newsletter2go_formcode:
      label: Formcode
      type: label