Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Self closing br tags are not allowed in translation import, therefore usage in t() breaks translation workflow, since translators tend to copy&paste the translation strings, leaving tags in place.
Proposed resolution
Replace <br/> with <br>.
Comment | File | Size | Author |
---|---|---|---|
#2 | 3037353.patch | 14.38 KB | volkerk |
|
Comments
Comment #2
volkerk CreditAttribution: volkerk at Thunder commentedComment #3
volkerk CreditAttribution: volkerk at Thunder commentedComment #4
gbyte CreditAttribution: gbyte as a volunteer and at gbyte commentedWhy is it not allowed, what's wrong with it? Any documentation you can point me to?
Comment #5
volkerk CreditAttribution: volkerk at Thunder commentedTranslated strings are validated by
locale_string_is_safe()
on import, self closing br without whitespace will fail becauseXSS::filter
will add whitespace, see #953582: locale_string_is_safe() will not allow self-closing tags without whitespace.I moved directly to simple <br> because html5 does not have a 'self closing tags' pattern, see reasoning in #1388926: Remove all references to "self-closing" void elements in core.
Anyway, using <br/> renders adding translations for these strings impossible.
Comment #7
gbyte CreditAttribution: gbyte as a volunteer and at gbyte commentedThanks for looking into this.