Making a string translation ready with html in it

Localizing a string with html markup inside the string can be a very opinionated story as you can see from one of my questions when I started out.

I would not say you are right, neither would I say that you are wrong, but I would say that your method is not prefered.

If you have a look at I18n for WordPress Developers, you’ll see that you should use printf() and placeholders when you have variables inside a string, well, the same applies for markup. My emphasis, you should never translate html tags, always use html tags outside of your string.

An example, with what I’ve just covered, should render a string like this

printf(__( '%s Hello %s world', 'textdomain' ), '<span>', '</span>' );