I have a view that expose a date filter with date_popup widget and using format 'd M Y' that I override through $date_element['#date_format'] = 'd M Y'. However an element with same format could be generated using the date element in a custom form array.

The problem with abbreviated dates is that the function date_month_names_abbr() call t() function without context when $length == 3 we need to consider that some months as "May" has the same full and abbreviated name. The length condition cause that for May the t() call with abbreviation context is never called. For a multilang site that context is very important because for example: in spanish May => Mayo (full name) and May => May (abbr name) so there is no way to correctly configure the translated name and date_month_names_abbr() returns wrong results:

Array (
[] =>
[Ene] => 1
[Feb] => 2
[Mar] => 3
[Abr] => 4
[Mayo] => 5
[Jun] => 6
[Jul] => 7
[Ago] => 8
[Sep] => 9
[Oct] => 10
[Nov] => 11
[Dic] => 12
)

Same thing happens for date_format_date() function that in the case of 'M' option in the format that should pass the abbreviation context to the t() function is calling to general translation.

I renenamed the context from simply "month_abbr" to "Abbreviation month name" for consistency compared to the other context "Long month name".

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

citlacom’s picture

Component: Code » Date API
Status: Active » Needs review
FileSize
1.86 KB

Here is a patch that resolved the problem.

Status: Needs review » Needs work

The last submitted patch, 1892898-fix-abbreviated-months-name-translation.patch, failed testing.