I would need to change "Please select an option." text on the woocommerce product page. Please check screenshots below, so you can see what I am talking about. Preview of the error message: I tried to use the following code, but it didnt do anything after I added it to functions.php file. function translate_error_message($translated_text, $text, $domain) { if ($translated_text == 'Please select an option.') { $translated_text = 'Vyberte jednu z možností.'; } return $translated_text; } add_filter('gettext', 'translate_error_message', 20, 3);
Jese Leos
August 21, 2024
Verified user
The HTML code is generated by javascript file "wpo-single-product.js" loaded by plugin "woocommerce-product-options". I couldn't find public documentation for this plugin so you have two options: Review plugin source code to find any possible filter wich may allow to modify the string, it might be using "wp_localize_script" function. Contact directly plugin author for the guidance how to translate the string.
Jese Leos
August 21, 2024
Verified user
Please try this code: //Change the Translate Text// function change_translated_text( $translated_text, $text, $domain ) { switch ( $translated_text ) { case 'Please select an option.': $translated_text = __( Vyberte jednu z možností.', 'your-text-domain' ); break; } return $translated_text; } add_filter( 'gettext', 'change_translated_text', 20, 3 );