Text for custom error (WP_Error) is translated into language default page
-
There is a handler for the form, in which, using the WP_Error class, I add custom error text, but it is not translated into other languages, but only into 1 language – Russian, since the main site is in Russian
<?php /** * Form contact us */ global $errors; $errors = new WP_Error; function handler_contact_us() { global $errors; if( empty($name) ) { $errors->add( 'name', __('Fill in the field "Your name"', 'my-text-domain') ); } if( $errors->has_errors() ) { wp_send_json_error($errors); } }
This error is displayed on the front through javascript, and the translation of the line in russian (default language on my website) is displayed there in all versions of the language, there are 5 of them on the site. Used WP Multisite.
Everywhere in the theme everything is correctly translated into other languages, but in this form handler in other versions of the language it is translated only into the main language, not even English, namely into Russian
That is, inside the function it does not work correctly, how to fix it?
- The topic ‘Text for custom error (WP_Error) is translated into language default page’ is closed to new replies.