0

I am trying to translate a few strings inside of a new plugin I'm about to release. I have a string set up like : <?php _e('The image <em>MUST</em> be less than <strong>500 KB</strong> in size.', CUSTOM_TEXT_DOMAIN); ?>

How would I go about escaping the elements so they are not included in the poedit translation?

Thanks!

1
  • am I correct to assume I should use: esc_html__( and esc_html_e(
    – EHerman
    Apr 3, 2014 at 18:58

1 Answer 1

2

I'd use printf to put the markup into place after the translation. You can force the order with the right modifiers, but translators are probably smart enough to not really need that.

printf( __('The image %sMUST%s be less than %s500 KB%s in size.', CUSTOM_TEXT_DOMAIN), '<em>', '</em>', '<strong>', '</strong>' ) ;

I consider Otto's post to be one of the definitive sources on how to translate strings in WordPress and one of his "rules" is don't translate HTML.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.