Today I worked with a wordpress site Bangladesh Linux Users Alliance, which is a complete Bangla language based site. You can translate with the Bangla language pack, but you can’t convert the English digits to it’s corresponding Bangla digit. So I visited the wordpress codex and found some filters that can do that job very easily.
Here is your function that will convert the digit
/**
* This function converts all english number's to bangla number
*/
function make_bangla_number($str)
{
$engNumber = array(1,2,3,4,5,6,7,8,9,0);
$bangNumber = array('১','২','৩','৪','৫','৬','৭','৮','৯','০');
$converted = str_replace($engNumber, $bangNumber, $str);
return $converted;
}
Now we need to add some filters that will hook to this places and convert the digit’s to Bangla.
add_filter( 'get_the_time', 'make_bangla_number' );
add_filter( 'the_date', 'make_bangla_number' );
add_filter( 'get_the_date', 'make_bangla_number' );
add_filter( 'comments_number', 'make_bangla_number' );
add_filter( 'get_comment_date', 'make_bangla_number' );
add_filter( 'get_comment_time', 'make_bangla_number' );
Read the rest of this entry »