Change "Add new comment" label

I added a new comment type, called Question. Unfortunately, it's hardcoded with "Add new comment" and looks exactly the same as any other comment type.

Different comment types look identical

 

Let's change that to say "Add new COMMENT_TYPE".

 

I just copied /core/modules/comment/templates/field--comment.html.twig into my theme and replaced the hardcoded text with the field label:

{% if comment_form %}
  <h2{{ content_attributes }}>{{ 'Add new comment'|t }}</h2>
 {{ comment_form }}

Becomes:

{% if comment_form %}
  <h2{{ content_attributes }}>{{ 'Add new ' ~ comment_type|t }}</h2>
 {{ comment_form }}

 

comment_type is a variable available in the template - check the comment block at the top of the file for other variables you can use.

~ is how you concatenate strings in Twig.

 

Add new COMMENT_TYPE displayed