Reverse the sentinel inclusion logic #3
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Reverse the sentinel logic and include the debug message only if sentinel=true. This way it must be explicitly set and avoids breaking the html-comment-wrapped sentinel message within html-comments and html-attributes.
Ref: https://github.com/syslabcom/oira.prototype/issues/559
The problem is that when we do not explicitly set
sentinel=falsea debug message in form of an HTML comment is rendered along with the translated string. But when a HTML comment is rendered as part of a HTML attribute value, this is broken HTML. The same goes for HTML comments within HTML comments. We have both cases in the oira.prototype (i18n translations are used within attributes and sometimes i18n translations are part of a commented-out HTML block.Currently there are many places where the i18n output is included like so:
This is the way to exclude the sentinel.
But we still have these cases:
And so on.
This would produce code like:
Instad of catching all cases where the sentinel needs to be excluded it's better to exclude it by default and only include it when needed.
I would strongly advise to consider this PR, unless there is an even stronger reason to not do so.