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.
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);
2
Answers
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.
Please try this code: