Translating day and date in Hindi in WordPress

Posted on March 23rd, 2011

While working for site of our Hindi newspaper Satta Ki Parakh, I got stuck in translating day and date for post’s date, comment’s date, etc{the_date()} in Hindi. There was nothing on WordPress and even Google was not able to help me…Finally I got solution with the help of a post for Bangla translation which can be employed in any wordpress theme which I want share with everyone.Here is the code that can be simply added to functions.php in your to perform this translation

 * This function converts all english days & months to hindi days & months
 function make_hin_str($str)
 $engStr = array(Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,January,February,March,April,May,June,July,August,September,October,November,December,Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec);
 $hinStr = array(रविवार,सोमवार,मंगलवार,बुधवार,गुरुवार,शुक्रवार,शनिवार,जनवरी,फरवरी,मार्च,अप्रैल,जून,मई,जुलाई,अगस्त,सितंबर,अक्टूबर,नवंबर,दिसंबर,जनवरी,फरवरी,मार्च,अप्रैल,जून,मई,जुलाई,अगस्त,सितंबर,अक्टूबर,नवंबर,दिसंबर);
 $converted = str_replace($engStr, $hinStr, $str);
 return $converted;
 add_filter( 'date', 'make_hin_str' );
 add_filter( 'get_the_time', 'make_hin_str' );
 add_filter('get_the_date', 'make_hin_str');
 add_filter( 'the_date', 'make_hin_str' );
 add_filter( 'get_comment_date', 'make_hin_str' );
 add_filter( 'get_comment_time', 'make_hin_str' );

4 Comments to “Translating day and date in Hindi in WordPress”

Leave a Comment