How to solve a translation function issue with no arguments and missing a text-domain?
Seems like the right thing to do there is to call esc_html instead of esc_html__. I have a feeling you don’t need any escaping there at all.
Seems like the right thing to do there is to call esc_html instead of esc_html__. I have a feeling you don’t need any escaping there at all.
Known bug, working on it: https://meta.trac.wordpress.org/ticket/2750 Always check the tickets first.
There is no way to know if string should be translatable or not (should a ‘fail’ in a json response be translatable?). Some things just need proper code review and can not be automated.
I created simple widget to find out why you have such a problem. Everything is working fine. Below I give you my code as an example. /** * Register widget */ function wpse_287570_register_widget() { register_widget(‘WPSE_287570_Widget’); } add_action(‘widgets_init’, ‘wpse_287570_register_widget’); /** * Create widget */ class WPSE_287570_Widget extends WP_Widget { public function __construct() { $op = array( … Read more
The default language of WordPress is always English (en-US). Regardless of what your site language is set to. This is what the entire WordPress community expects for the language of source strings, and how many translation projects for WordPress will be set up too. So yes, it is bad practice to choose use different source … Read more
As you already have the author’s ID, you can create a new WP_Query and get the 3 latest posts of the Author. The following code will do the job for you, $getPosts = new WP_Query( array( “author” => $user->ID, // This tells the query which author’s post you want to get. “posts_per_page” => 3, // … Read more
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
Apply to become a translator If you want to provide your own translations, you have to post a request at https://make.wordpress.org/polyglots/ stating which languages you want to translate yourself, so this implies that you actually speak those languages fluently. This is what I have done and what I will describe in this answer. But if … Read more
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
You need to do “msgfmt” using the command line tool to convert the .po to a .mo, that is what WordPress (and all gettext compliant software) uses.