I'm using the monthly archive view which comes bundled with the Views module, but I'm developing a website in a different language and I'm unable to translate month names. I tried string overrides, and I also tried to play around with locale settings, but nothing seems to be working. Does anyone know how to do this fairly easily?

Thanks,
Jane

Comments

dmcdenissen’s picture

Search within translate interface for the keyword: !long-month-name

You will get the translations of all the month names, and you can edit it into the language you have active.
note: You need to add the !long-month-name before every month name translation.

I hope this is the answer you were looking for...

erlendoos’s picture

Month names are not added automatically.

As explained here: https://localize.drupal.org/node/2109

Add translation strings for month names by a simple module (create it yourself!) to call t() with the month name and context. Translate to the required languages afterwards.

function monthname_install() {
  $months = array(
    'January',
    'February',
    'March',
    'April',
    'May',
    'June',
    'July',
    'August',
    'September',
    'October',
    'November',
    'December',
  );
  
  $options['context'] = 'Long month name';

  foreach($months as $m) {
    t($m, array(), $options);
  }
  
  drupal_set_message(t('Month names have been made available for translation. The rest is up to the translation team :-)'));
}

function monthname_cron() {
  drupal_uninstall_modules(array('monthname'));
}
Overflowed’s picture

Hi.

The above didn't work for me. I solved it by using locale() instead of t() :

function monthname_install() {

  $months = array(
    'January',
    'February',
    'March',
    'April',
    'May',
    'June',
    'July',
    'August',
    'September',
    'October',
    'November',
    'December',
  );

  foreach($months as $m) {
    locale( $m, 'Long month name' );
  }

  drupal_set_message(t('All long month names have been made available for translation.'));
}

LINKS:

https://api.drupal.org/api/drupal/modules%21locale%21locale.module/funct...