How to translate any string in woocommerce

Today i will share with you guys that how can you translate any string for woocommerce using php

add_filter('gettext',  'translate_text');
add_filter('ngettext', 'translate_text');

function translate_text($translated) {
$translated = str_ireplace('Choose and option', 'Select', $translated);
return $translated;
}