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.
Related Posts:
- How to get a translated string from a language other than the current one?
- How to get a localized version of WordPress from a repository?
- Working with l10n contexts (_x etc)
- How to escape the single quote character in i18n translation strings?
- How to escape single and plural i18n text strings?
- What are the most used WordPress localization?
- Difference between 2 internationalization (i18n) functions __() & _e()
- Localization works but still get “This plugin is not properly prepared for localization” msg in directory
- How to load theme textdomain from plugin?
- get_the_date() for translating date format
- Should i use _n for pronouns in translation?
- POEdit with Custom mu-plugins code
- How does WordPress choose which translation file to use?
- Proper way to create / manage gettext (.po, .pot) files?
- Should I include colon in my msgid in PO file?
- _e() function get text_string from function
- Translations not returning translated strings
- Force translated language on front
- Translating dynamic strings
- WordPress translation loading english file
- Easy export/import of data for Translation
- WordPress Theme .mo-file won’t load
- How to become a translator on wordpress.org?
- Translation from .mo file not working in theme
- WordPress localization – gettext and git
- Can I set WordPress to display languages based on system language without a plugin?
- /languages/ folder missing in default themes
- How to translate functions.php?
- WordPress Translations
- Post types translation
- Translate arguments of a user added custom code [closed]
- Internationalize plugin so strings can be translated in WPML [closed]
- localization of theme and plugins to English (originally in another language)
- Interface translation without plugins
- Plugin localization persistance (woocommerce)
- WordPress Localization error within return value
- Custom theme .mo translation file not working
- Plugin translation not displaying
- WordPress translation
- Tweak the loop for translation
- Translating form labels shortcode output
- Website Language/Locale Switching
- .po file is loaded but changes are not appearing
- How to create .pot files with POedit?
- Translate a plugin using .po .mo files
- How to make a WordPress plugin translation ready?
- Theme localization of “slugs” (custom post types, taxonomies)
- Override default WordPress core translation
- Different Language for Frontend vs Backend
- Custom strings for translation using Polylang plugin
- How to print translation supported text with HTML URL
- Localization: I want the backend: english and frontend in defined language
- How-to: Translate plural forms for themes/plugins with PoEdit
- generating po mo translating files from scratch in a wordpress theme
- How to integrate get_post_time with date_i18n function?
- gettext does not translate when called in ajax
- How to debug failed load_theme_textdomain()?
- How to provide translations for a WordPress TinyMCE plugin?
- How do translated, escaped strings (esc_attr) in Themes work?
- Changing the language of a single page
- what’s different between _x() and _()
- How to handle text with function __(?
- Obtain a list of available translations
- How do I translate: “2 hours and 15 minutes”?
- Disabling Translation Update
- Gettext details
- custom theme: english .mo file not working
- Unknown language json files
- How to save a translation of a plugin in “CodeStyling Localization”?
- Best pratice to make taxonomy terms translatable without changing slugs?
- Set language per post
- List of Default Translated Phrases
- What is the purpose of an extra file for translation?
- How to add extra language packs to WordPress
- load_plugin_textdomain in `plugins_loaded` or `init`?
- How to extract translatable (double underscores and _e) strings?
- How to Translate Contact Form 7 using qTranslate? [closed]
- How to set locale in ajax requests?
- Translate Navigation Menu & Sidebar Widget Titles
- Problems with localization
- Translate content, not instance, per-post
- Best location for theme translation files
- `wp_set_script_translations` with `wp.i18n` does not return translated strings in simple plugin
- Localization / textdomain is slow and chaotic
- Why should I escape translatable strings? and how shall i do that?
- Can’t translate the post meta data (Date) in another language
- Change language of comments template
- How to handle single quote in a translatable string in WordPress
- Make theme translatable for WPML
- Can’t we use strings defined as PHP constants if we want to translate them in a plugin?
- WordPress: After Gutenberg plugin migration to block.json the localization/ translations with PolyGlot in JavaScript does not work anymore
- Translation of plugin in MU-PLUGINS directory not working
- How can I make “Leave a comment” translation ready?
- Custom translation of Month names
- I can’t translate text in my plugin using a .mo file, load_plugin_textdomain() function is always false
- Multiple text-domains per single plugin – admin and frontend
- How to add translation for a string
- How to translate a WordPress.org plugin?
- Where the WordPress Core Translation is “actually” taking place?
- How do I translate this string – PHP syntax question