Localization, escape html elements mid-sentence

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 … Read more

WordPress Translation Issue

You are exploding the text with explode( ‘ ‘, $ctxttext ). Therefore you are translating word by word, not strings. That is why it’s working with single word string, and not with multiple words. When you call First Name you are translating First and Name. Cheers

Translation from .mo file not working in theme

Start a new theme from scratch to see if you have the same result. I test with theses files and the translation works style.css /* Theme Name: My Theme */ functions.php <?php add_action( ‘after_setup_theme’, ‘my_theme_load_theme_textdomain’ ); function my_theme_load_theme_textdomain() { load_theme_textdomain( ‘my-theme’, get_template_directory() . ‘/languages’ ); } languages/es_ES.po (file languages/es_ES.mo created with poedit) msgid “Featured” msgstr … Read more

Using _e() or __() to translate text with div

None of them are correct. These APIs are not intended for dynamic data or content in the database. This would be the best practice answer: echo ‘<h2 class=”title”>’; esc_html_e( ‘static string’, ‘text-domain’ ); echo ‘</h2>’; If you want to translate posts and other database user entered content, use a translation plugin, not the localisation API. … Read more