How to override confirmation messages when saving or updating content in Drupal 8? I've got a few taxonomy vocabularies, but the confirmation message on save/update is generic - Created new term %term. or Updated term %term..
Those messages come from \Drupal\taxonomy\TermForm.
Usage of that class is defined in \Drupal\taxonomy\Entity\Term class annotation.

I would like to have custom confirmation messages specific to each vocabulary.

What's the best way to accomplish that? Ideally I'd like to have separate form handler classes for each vocabulary.
Don't know if that's the best way, but it worked for me.

In your my_module.module:


/**
 * Implements hook_entity_type_alter().
 *
 * @param \Drupal\Core\Entity\EntityTypeInterface[] $entity_types
 *
 */
function my_module_entity_type_alter(array &amp;$entity_types)
{
    $entity_types['taxonomy_term']-&gt;setFormClass('default', '\Drupal\my_module\Form\MyTermForm');
}


Create my_module/src/Form/MyTermForm.php and override the save() method of Drupal\taxonomy\TermForm.

/**
 * @file
 * Contains \Drupal\my_module\Form\MyTermForm.
 */

namespace Drupal\my_module\Form;

use Drupal\Core\Form\FormStateInterface;
use Drupal\taxonomy\TermForm;

class MyTermForm extends TermForm
{

    /**
     * {@inheritdoc}
     */
    public function save(array $form, FormStateInterface $form_state) {
        $term = $this-&gt;entity;

        $result = $term-&gt;save();

        $link = $term-&gt;link($this-&gt;t('Edit'), 'edit-form');
        switch ($result) {
            case SAVED_NEW:
                drupal_set_message($this-&gt;t('Created new :type %term.', array(':type' =&gt; $this-&gt;getType($term), '%term' =&gt; $term-&gt;getName())));
                $this-&gt;logger('taxonomy')-&gt;notice('Created new :type %term.', array(':type' =&gt; $this-&gt;getType($term), '%term' =&gt; $term-&gt;getName(), 'link' =&gt; $link));
                break;
            case SAVED_UPDATED:
                drupal_set_message($this-&gt;t('Updated :type %term.', array(':type' =&gt; $this-&gt;getType($term), '%term' =&gt; $term-&gt;getName())));
                $this-&gt;logger('taxonomy')-&gt;notice('Updated :type %term.', array(':type' =&gt; $this-&gt;getType($term), '%term' =&gt; $term-&gt;getName(), 'link' =&gt; $link));
                break;
        }

        $current_parent_count = count($form_state-&gt;getValue('parent'));
        $previous_parent_count = count($form_state-&gt;get(['taxonomy', 'parent']));
        // Root doesn't count if it's the only parent.
        if ($current_parent_count == 1 &amp;&amp; $form_state-&gt;hasValue(array('parent', 0))) {
            $current_parent_count = 0;
            $form_state-&gt;setValue('parent', array());
        }

        // If the number of parents has been reduced to one or none, do a check on the
        // parents of every term in the vocabulary value.
        $vocabulary = $form_state-&gt;get(['taxonomy', 'vocabulary']);
        if ($current_parent_count &lt; $previous_parent_count &amp;&amp; $current_parent_count &lt; 2) {
            taxonomy_check_vocabulary_hierarchy($vocabulary, $form_state-&gt;getValues());
        }
        // If we've increased the number of parents and this is a single or flat
        // hierarchy, update the vocabulary immediately.
        elseif ($current_parent_count &gt; $previous_parent_count &amp;&amp; $vocabulary-&gt;getHierarchy() != TAXONOMY_HIERARCHY_MULTIPLE) {
            $vocabulary-&gt;setHierarchy($current_parent_count == 1 ? TAXONOMY_HIERARCHY_SINGLE : TAXONOMY_HIERARCHY_MULTIPLE);
            $vocabulary-&gt;save();
        }

        $form_state-&gt;setValue('tid', $term-&gt;id());
        $form_state-&gt;set('tid', $term-&gt;id());
    }

    /**
     * @param \Drupal\taxonomy\TermInterface $term
     */
    private function getType($term)
    {
        $vocabularyId = $term-&gt;getVocabularyId();
        switch ($vocabularyId) {
            case 'pages':
                return 'page';
            default:
                return 'term';
        }
    }

}