Forums

[resolved] comment_date does not translate (2 posts)

  1. kimmeehh
    Member
    Posted 3 years ago #

    Hello guys and galls

    I use DutchDate http://wordpress.org/extend/plugins/dutchdate/ to translate dates in a wordpress blog. It works nice. I changed it a bit, so now it also changes the first capital of the month name.

    It works for the_time, the_date, and prolly also for the_modified_date and the_modified_time.

    It does a simple replace (i deleted all values but one for the sake of brevity):

    function multipop_date_replace($text) {
    	$days_english = array('Monday');
    	$days_dutch = array('Maandag');
    	$text = str_replace($days_english, $days_dutch, $text);
    	return $text;
    }

    And then it does:

    add_filter('the_time', 'multipop_date_replace');

    I assumed that adding

    add_filter('comment_date', 'multipop_date_replace');

    would do the trick to also change the date below comments. It does not.

    <a href="#comment-<?php comment_ID() ?>">
        <?php comment_date('j F Y') ?> om <?php comment_time() ?> uur
    </a>

    returns: 17 March 2009 om 16:35 uur

    whereas

    <small><?php the_time('l j F Y \o\m H:i \u\u\r') ?></small>

    returns: Dinsdag 17 maart 2009 om 16:30 uur

    Can anyone help me please?
    Cheers

  2. kimmeehh
    Member
    Posted 3 years ago #

    Well, a mail from the creator of the plugin gaven me the answer :-)
    I am happy now. He will update the mod, but i will also post it here for reference:

    Add the following line to the bottom of the file, so just below 'add_filter('the_modified_date', 'multipop_date_replace');'

    add_filter('get_comment_date', 'multipop_date_replace');

    use the following code in the comment.php

    <a href="#comment-<?php comment_ID() ?>">
       <?php echo get_comment_date('j F Y') ?> om <?php comment_time() ?> uur
    </a>

    The get_comment_date does work, the comment_date does not :-) Don't forget to add 'echo' before 'get_comment_date'

    Cheerios!

Topic Closed

This topic has been closed to new replies.

About this Topic