How to translate custom date formats? I created a custom date format j F Y at Configuration » Regional and language » Date and time » Formats. I'm pleased with the overall look, but I'd like the months to be written in Dutch instead of the default English. The month names should be translated everywhere they occur and it would be perfect if the days should be translated too (maybe I'll need them in the future).

How can I do this?
This is a lot harder to do than I first thought.  Formatted dates, including strings for the month (and day) names are produced by format_date().  This function is not themable, and there is no hook to override it.

That means that (AFAIK) there is no right way to change how this function behaves (the wrong way is to hack it - i.e. hack core - which is not an option in my book).

What we can do is to make a tiny custom module with a version of this function that outputs months and days in Dutch, no matter what the default language for the site is.  This function will do this:

function MYMODULE_format_date($timestamp, $type = 'medium', $format = '', $timezone = NULL) {
  return format_date($timestamp, $type, $format, $timezone, 'nl');
}


(Where MYMODULE is the name of your custom module.)

Now, if you set the default language of your site to English, but keep the Dutch translation available, one of the following calls:

MYMODULE_format_date($timestamp, $type);
MYMODULE_format_date($timestamp, 'custom', 'j F Y');


(where $timestamp is the timestamp to print and $type is the format to use) will output names of months and days in Dutch, but everything else will be in your site's default language.  The first will do this for any valid format (Long, Medium, Short, etc.), the second for the custom format 'j F Y'.

This will give you Dutch month names if you call this custom function instead of the standard one when outputting formatted dates.

However, it will not change the output in existing code which of course uses the standard version of the function.  This may not be a problem for you, since you want to use it with a custom date format (which obviously is not in use in legacy code), but I still want to make that clear.

If you want to change how months and days are spelled everywhere, you need to override the templates node.tpl.php and comment.tpl.php (and possibly other templates that uses format_date). In the override, just replace any calls to format_date with calls to MYMODULE_format_date.