Date formats with abbreviated month name (M) are not translated using context

Created on 4 October 2018, about 6 years ago
Updated 21 February 2023, almost 2 years ago

Problem/Motivation

When creating or modifying a translated date format which uses the abbreviated month name (M), the translations (Jan, Feb, Mar, etc.) will not use the 'context' related interface translation.

For example, the French interface translation for 'May' should provide two source strings; May and May with context: abbreviated month name. Assume we translate May to peux and May with context to mai. All content date fields which uses the date format with the abbreviated month (M) will display the month of May as peux when it should be mai.

Steps to reproduce:

  1. Clean drupal 8.6.1
  2. Modules: Language, Configuration Translation, Content Translation,Interface Translation
  3. Install second language (example; French).
  4. Allow content to be translated (and date field). /admin/config/regional/content-language
  5. Date and time format; add custom medium date with abbreviated month (M). For example: Name=shortened_medium_date Format String= M d, y /admin/config/regional/date-time
  6. Add a French translation for the custom medium date. For example: Format String= d M, y /admin/config/regional/date-time/formats/manage/shortened_medium_date/translate
  7. Update language translations (French). /admin/reports/translations
  8. Using Interface Translation, search French Language for 'May' and set May to peux and May with context: abbreviated month name to mai. /admin/config/regional/translate
  9. Modify basic page, add a date or timestamp field, and set the field display to the custom medium date format created in step 5.
  10. Create new basic page content and set date field to May 1, 2018.
  11. Translate the new basic page to French and set date field to May 1, 2018.
  12. View the new page with /fr/. The date should be 1 mai, 2018 but it will be 1 peux, 2018.

Proposed resolution

Modify the DrupalDateTime format function to set context = Abbreviated month name when code = M.

Remaining tasks

  • Create patch. (Done)
  • Test.

User interface changes

none

API changes

none

Data model changes

none

Original report by [username]

none

Feature request
Status

Needs work

Version

10.1

Component
Locale 

Last updated 4 days ago

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024