Translations in source code

This is “normal” in WordPress 5 as this is what the new wp_set_script_translations function is for. The function tells WordPress to associate a JSON file containing translations with a specific script that will make use of them. It makes use of them as you see, by embedding the translations as JavaScript objects. You say this … Read more

Archive widget numbers translation?

For archives you can use the get_archives_link filter like this: add_filter(‘get_archives_link’, ‘translate_archive_month’); function translate_archive_month($list) { $patterns = array( ‘/January/’, ‘/February/’, ‘/March/’, ‘/April/’, ‘/May/’, ‘/June/’, ‘/July/’, ‘/August/’, ‘/September/’, ‘/October/’, ‘/November/’, ‘/December/’ ); $replacements = array( //Put here whatever you want ’01’, ’02’, ’03’, ’04’, ’05’, ’06’, ’07’, ’08’, ’09’, ’10’, ’11’, ’12’ ); $list = preg_replace($patterns, … Read more

How to translate placeholder?

In your code, you are concatenating a string but you are (from a comment) using a function that echos information– _e(). You can’t do that. You are printing the content wherever that array is constructed, which is not what you want. Use __() instead.

Translating form labels shortcode output

If anyone is looking for a solution, here is a way (probably not the better one) to achieve it: add_filter(‘widget_text’, ‘filtering_form_labels’); function filtering_form_labels($html) { if ( ICL_LANGUAGE_CODE==’en’ ) {/*ICL_LANGUAGE_CODE used in WPML to know the active language*/ $esp = array(‘Nombre’, ‘Apellidos’, ‘Suscribirse’); /*Array with words to be replaced*/ $eng = array(‘First Name’, ‘Last Name’, ‘Subscribe’); … Read more

White Space on translated strings lost

The actual code is <?php /* translators: used between list items, there is a space after the comma */ $tags_list = get_the_tag_list( ”, __( ‘, ‘, ‘timo’ ) ); if ( $tags_list ) : ?> <span class=”tags-links”> <?php printf( __( ‘Tagged %1$s’, ‘timo’ ), $tags_list ); ?> </span> <?php endif; // End if $tags_list ?> … Read more