Wordpress前端显示不同的语言,有什么不对?

时间:2012-02-11 23:53:39

标签: php wordpress datetime datetime-format

我试图找到这个问题的解决方案好几个小时但无济于事。我在英语中使用wordpress 3.3.1,我已将wp-config.php中的语言环境设置为瑞典语,并将瑞典语语言文件(sv_SE.mo和sv_SE.po)上传到languages文件夹。 “管理”面板现在显示为瑞典语以及前端发布日期和评论日期,而前端评论回复日期仍以英语显示。

以下是我的评论模板(functions.php)中的代码,可能会有所帮助。提交日期格式有两行 - 从顶部开始的第九行和从底部开始的第四行。在这两种情况下,日期格式都以('j M Y H:i')给出,但它们以不同语言输出日期。最上面的日期产生瑞典日期,而最低日期输出英文。我想用瑞典语显示所有日期。

我试图破解locale.php文件中的月份名称,但没有任何反应。有什么想法有什么不对?非常感谢您的帮助。

<li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
<div id="comment-<?php comment_ID(); ?>">
<div class="comment-body">
<div class="comment-meta commentmetadata">
<div class="commenter-info"><span class="commenter"><?php printf( __( '%s', 'mytheme' ), sprintf( '<cite class="fn">%s</cite>', get_comment_author_link() ) ); ?><br/></span><!-- commenter -->
<div class="comment-date">
<?php
        /* translators: 1: date */
        printf( __( '%1$s', 'mytheme' ), get_comment_date('j M Y H:i') ); ?><?php edit_comment_link( __( 'Edit &rarr;', 'mytheme' ), ' ' );
?>
</div><!-- comment-date -->
</div><!-- commenter-info -->

<div class="comment-gravatar"><?php echo get_avatar( $comment, 65 ); ?></div>

<span class="reply">
<?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
<a class="comment-reply-link" href="?replytocom=<?php comment_ID(); ?>#respond" onclick="return addComment.moveForm('comment-<?php comment_ID(); ?>', '<?php comment_ID(); ?>', 'respond', '<?php echo $post->ID; ?>')">Svara</a>
</span><!-- reply -->

</div><!-- .comment-meta .commentmetadata -->

<div class="comment-content">
<?php comment_text(); ?>
</div><!-- comment-content -->

<!-- comment reply link -->         
<?php
    if ( $comment->comment_parent ) {
         $parent = get_comment( $comment->comment_parent );
         $parent_link = esc_url( get_comment_link( $comment->comment_parent ) );
         $date = DateTime::createFromFormat('Y-m-d H:i:s', $parent->comment_date);
         $parent->comment_date = $date->format('j M Y H:i');
         printf( '<span id="inreplyto">Svar till <a href="%1$s">%2$s %3$s</a></span>', $parent_link, $parent->comment_author, $parent->comment_date );
} ?>

1 个答案:

答案 0 :(得分:0)

实际上无法找到解决方案,因此我使用瑞典语版本进行了新的wordpress安装,解决了这个问题。