How to translate month names in “Archives”

How can I modify month names in “Archives” in my blog? I would like to translate english month names into my mother tongue. I’m using the english version of wordpress 3.1.3

Related posts

Leave a Reply

4 comments

  1. if the translation is only for the archive widget, a filter function might work (to be added to functions.php of the theme):

    add_filter('get_archives_link', 'translate_archive_month');
    
    function translate_archive_month($list) {
      $patterns = array(
        '/January/', '/February/', '/March/', '/April/', '/May/', '/June/',
        '/July/', '/August/', '/September/', '/October/',  '/November/', '/December/'
      );
      $replacements = array(
        'jan', 'feb', 'mar', 'apr', 'may', 'jun', 
        'jul', 'aug', 'sep', 'oct', 'nov', 'dec'
      );    
      $list = preg_replace($patterns, $replacements, $list);
    return $list; 
    }
    
  2. I made a function in ‘functions.php’:

    function mes($month) {
    switch ($month) {
    case 1:
        $m_es = "ene";
        break;
    case 2:
        $m_es = "feb";
        break;
    case 3:
        $m_es = "mar";
        break;
    case 4:
        $m_es = "abr";
        break;
    case 5:
        $m_es = "may";
        break;
    case 6:
        $m_es = "jun";
        break;
    case 7:
        $m_es = "jul";
        break;
    case 8:
        $m_es = "ago";
        break;
    case 9:
        $m_es = "sep";
        break;
    case 10:
        $m_es = "oct";
        break;
    case 11:
        $m_es = "nov";
        break;
    case 12:
        $m_es = "dic";
        break;
    }
    return($m_es); }
    

    Assigning every numeric value of the months to the translation I would like to show.

    Then on my ‘single.php’ I just gave it some format:

    <?php echo get_the_date('d') . '.' . mes(get_the_date('n')) . '.' . get_the_date('y'); ?>
    

    It’s worked for me.

    Saludos!