I collected a good numerals replacing function for WordPress calendar:
function make_bangla_number($str)
{
$engNumber = array('0','1','2','3','4','5','6','7','8','9');
$bangNumber = array('০','১','২','৩','৪','৫','৬','৭','৮','৯');
$converted = str_replace($engNumber, $bangNumber, $str);
return $converted;
}
The function clearly stating that, it's taking English numerals and just replacing them with Bānglā numerals.
But the problem is with a similar function I can replace all the Gregorian Months to Bānglā scripts, but using the numerals function, I'm messing the calendar widget. Because calling:
add_filter( 'get_calendar', 'make_bangla_number' );
replaces all the numerals, even in the HTML. Suppose the previous month link in HTML:
<td id="prev" colspan="3">
<a title="View posts for October 2013" href="http://localhost/wp_developer/?m=201310">
« Oct
</a>
</td>
getting...
<td id="prev" colspan="৩">
<a title="View posts for অক্টোবর ২০১৩" href="http://localhost/wp_developer/?m=২০১৩১০">
« অক্টোবর
</a>
</td>
So there are two problems:
- The anchor is getting wrong path so the archive URL is not isset (
?m=২০১৩১০
) - The structure of Widget archive is breaking, because the HTML is getting wrong value for HTML properties (
colspan="৩"
)
And you all know that all the Unicode numerals can be equal in Numerical value, but not equal to their Binary value. So the Latin Numeral 1
is not equivalent to Bānglā Numeral ১
in compare to their Binary value.
So,
HOW CAN WE PROCEED WITH SUCH A FILTER/HOOK IN A SAFE WAY?