Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question
    
How do you show the month's name in the "Archives" page? –  Rilwis Jun 5 '11 at 15:33
    
May 2011, June 2011 etc. Just like e.g in this blog: blog.sqlauthority.com –  jrara Jun 5 '11 at 17:57
    
No, I meant which code are you using to show month's name, not how they're shown :D –  Rilwis Jun 6 '11 at 1:15

4 Answers 4

up vote 1 down vote accepted

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; 
}
share|improve this answer
    
Great, works really well! –  jrara Jun 6 '11 at 5:42

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!

share|improve this answer
    
Just for your information: You can save yourself some code/effort and directly return the string for each case, meaning: case 1: return "ene"; case 2: return "feb"; .... That way you don't need any variable, don't need to instantiate, don't need any break;, and thus have less code. –  t f Apr 18 '13 at 20:45
    
Excellent! thanks for the tip –  Angel Gtz Apr 27 '13 at 22:57

Depends on your theme, but some language strings may be coded in the archives.php file. Check that and also see http://codex.wordpress.org/I18n_for_WordPress_Developers

share|improve this answer

I believe the WordPress Multilingual plugin will do this, though I have not used it.

share|improve this answer
    
Yes, but I don't want to change the whole language of my blog, just those month names. –  jrara Jun 5 '11 at 17:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.