如何本地化wordpress帖子视图的数量?

时间:2012-10-19 08:33:56

标签: wordpress localization wordpress-plugin indic

我想在本地化号码中显示帖子视图。我在function.php中添加这些函数来执行此操作

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;
}

add_filter( 'the_views', 'make_bangla_number' );

但是我无法在本地化中显示该数字。每当我调用the_views时,它会显示英文编号。知道如何用本地化语言显示帖子视图号吗?

有关详细信息,请参阅我的帖子查看功能:

// function to count post views.
function setPostViews($postID) {
    $count_key = 'views';
    $count = get_post_meta($postID, $count_key, true);
    if($count==''){
        $count = 0;
        delete_post_meta($postID, $count_key);
        add_post_meta($postID, $count_key, '0');
    }else{
        $count++;
        update_post_meta($postID, $count_key, $count);
    }
}
// function to display number of post views.
function the_views($postID){
    $count_key = 'views';
    $count = get_post_meta($postID, $count_key, true);
    if($count==''){
        delete_post_meta($postID, $count_key);
        add_post_meta($postID, $count_key, '0');
        return "0 View";
    }
    return $count.' বার';
}

1 个答案:

答案 0 :(得分:2)

帕尔韦兹,

WordPress中有支持Bangla语言的支持,请参阅http://codex.wordpress.org/WordPress_in_Your_Language#Bangla_-Bengali.28bn_BD.29

您必须安装Bangla语言包到您的WordPress,您可以从以下链接找到...

http://svn.automattic.com/wordpress-i18n/bn_BD/trunk/messages/

http://www.shadhinbangla.com/wordpress-bangla-language-pack-beta-3/2011/10/

此外,您必须在HTML代码中检查CHARSET必须设置为UTF-8,并且必须使用Collat​​ion CHARSET UTF-8创建MySQL数据库以将Bangla值存储在DB中。

另外,我发现了一个旧的WordPress插件来显示Date&在Bangla的时候,你可以参考他们的代码来解决你的问题。这是插件链接...   http://wordpress.org/extend/plugins/bangla-numbers-in-date-and-time/

或者您可以向WordPress支持团队寻求帮助。

嘿,我最近在WordPress中找到了设置Bangla语言的详细草稿,请参考此链接... http://www.lavluda.com/2008/11/08/wordpress-with-full-bangla-language-support/