When setting up an entity bundle to be translatable, people have a choice of making each field translatable or not.
When a node gets an error for example because you try to save a node with required fields.
The label name is used in the error message as "@name is required".
Because content translation is putting (all languages) after the label this is also appearing in the error message.
So the error will be: "Field 1 (all languages) field is required."
But the current message is "Field 1 <span class="translation-entity-all-languages">(all languages)</span> field is required."
Problem: HTML is not rendered well in the error message.

| Comment | File | Size | Author |
|---|---|---|---|
| #29 | 2899338-29.patch | 1.11 KB | pobster |
| #28 | html-validation-error-screenshot.png | 476.94 KB | kumudb |
| #21 | interdiff_2899338_19-21.txt | 1.57 KB | ankithashetty |
| #21 | 2899338-21.patch | 1.07 KB | ankithashetty |
| #19 | core-format_translation_hint_suffix-2899338-19.patch | 1.92 KB | cchiste |
Issue fork drupal-2899338
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
martijn de witComment #3
martijn de witComment #4
martijn de witComment #6
falco010Created a patch that removes the span HTML. Does anyone know if this HTML is needed for anything? I could not find any code that is using the 'translation-entity-all-languages' class.
Comment #7
falco010Comment #8
martijn de witComment #9
jonathan1055 commentedWill this problem be solved by #2652850: Title for details form elements is not set as '#markup' and it will be escaped, but all other form elements use '#markup' and are not escaped?
It does solve #2833031: Field label shows HTML if field is marked as not translatable which is almost the same.
Comment #10
martijn de wit@jonathan, Yes I think if everything is rendered by #markup there will be no issue any more. Didn't test is yet.
Comment #13
stockticker commentedI had a similar issue recently on one of the projects.
Attaching a patch.
I.e. HTML markup is still being escaped for the validations errors (so issues above do not resolve this problem)
Comment #14
martijn de witComment #15
martijn de witComment #16
martijn de witsry... I think I was sleeping while changing the version...
Comment #18
cchiste commentedPatch applies and works for inline errors in Drupal 9.2.x
Comment #19
cchiste commentedI was still noticing raw html in error messages at the top of the page and decided to track this down to the source. Submitted patch formats the combined title and translation hint suffix for html display.
Comment #20
feuerwagenThanks for the patch. Some nitpicks:
Unrelated formatting change.
This can be one line.
Other than that, I'm pretty sure this needs a test to make sure that HTML in the field label is rendered correctly in the error message. What I'm not sure about: Is the translation hint the only place where HTML is added to the field label? Or can we find a more general approach to this?
Comment #21
ankithashettyAddressed the changes specified in #20.1 and #20.2, thanks!
Comment #27
jonathan1055 commentedFixed issue summary to correctly show the < and >
Comment #28
kumudbIt appears that this issue has been resolved in the latest version of Drupal 11. I have tested the scenario and verified that the error message no longer includes the "(all languages)" suffix.
I have attached a screenshot for reference. Given that the problem is no longer present, I believe we can close this issue.
Thank you!
Comment #29
pobster commentedNot everyone is on 11.x yet... This is rerolled for 10.3.x.
Comment #30
quietone commentedChanges are made on on 11.x (our main development branch) first, and are then back ported as needed according to the Core change policies.
This is changing a user facing error message so will need before and after screenshots. They should be available to reviewers/committers from the Issue Summary.
This also needs an issue summary update, add the standard issue template and complete the 'Problem/Motivation', 'Steps to reproduce', and 'Proposed resolution' sections. Leave the other sections empty for use by other contributors.
Comment #31
pobster commentedhttps://www.drupal.org/project/drupal/issues/2899338#comment-15774058
Comment #32
quietone commented@pobster, thanks for repeating that this is fixed in D11. I couldn't find the issue where this was fixed but it wasn't backported to D10.
Thanks everyone for working on this issue. The current error message should render the HTML correctly, However, this
I agree that the current string is somewhat misleading, and the suggested change would improve it. However, Drupal 10 is in maintenance mode and this issue doesn't meet the criteria for an allowed change in a maintenance minor,
Therefor, I am closing this issue as won't fix.