[11.x] Add replaceable tags to translations #51190
Merged
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.
Turned #51188 into a PR.
When writing translations there are times when you may want to inline some HTML, such as for bolding some text or placing a link in the middle of a sentence, currently, you can achieve this by doing something along the lines of:
But this isn't very nice or readable to a translator, FormatJS already has a solution to this with Tag Replacements, these look like normal HTML tags but they don't support attributes, they can be added with callable:
This takes the complexity away from the translator (as in the person, not the class), and makes the code more maintainable if you want to modify that anchor tag with a class then you don't have to go through each translation to add it.
This still requires the usage of unescaped echos within blade, I'm happy to accept any ideas for making this into a
HTMLString
to avoid this but I didn't want to pile too much into this merge.This change should be fully backwards compatible.