I have the following code in my custom block:

    public function blockForm($form, FormStateInterface $form_state) {
    $form = parent::blockForm($form, $form_state);

    $config = $this->getConfiguration();

    $form['headline'] = array(
      '#type' => 'textfield',
      '#title' => $this->t('Block headline'),
      '#default_value' => isset($config['headline']) ? $config['headline'] : NULL,
      '#required' => TRUE,

      return $form;


    public function blockSubmit($form, FormStateInterface $form_state) {
      $this->setConfigurationValue('headline', $form_state->getValue('headline'));

The configuration is saved correctly, but only for English language.
The block translation doesn't show my variable (headline) in the translatable configuration.
What am I doing wrong?



1 Answer 1


You have to provide a schema in /config/schema/mymodule.schema.yml of the type block_settings.


  type: block_settings
  label: 'Example configurable text block configuration'
      type: text
      label: 'Block contents'

From the example module https://git.drupalcode.org/project/examples/-/blob/HEAD/modules/block_example/config/schema/block_example.schema.yml

Configurations mapped as type: label (single line of text) or type: text (multiple lines of text) are translatable.

  • 2
    Thanks! Can I add it anytime after enabling the module? Or do I need to add these values through a hook_update_N()? Commented Jun 27, 2017 at 20:15
  • 2
    the new schema yaml is discovered when you clear the cache
    – 4uk4
    Commented Jun 27, 2017 at 20:21
  • 2
    We dedicated a blog post about Config Translation (schema, default value, UI) in Drupal 8 with a full example: antistatique.net/en/we/blog/2018/05/01/…
    – GiDo
    Commented May 3, 2018 at 11:18
  • 1
    @GiDo great article! Can you advice: are theme_setting translatable? Cant make them work normal with translation :( Commented Jul 31, 2019 at 19:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.