WordPress.org

Make WordPress Core

Opened 3 weeks ago

Last modified 30 hours ago

#48606 reviewing defect (bug)

Some date formats get incorrectly output in Italian

Reported by: Clorith Owned by: SergeyBiryukov
Milestone: 5.3.1 Priority: normal
Severity: normal Version: 5.3
Component: Date/Time Keywords: has-patch has-unit-tests
Focuses: Cc:
PR Number:

Description

When using the date format l j F Y (Monday 11 November 2019), and changing the site language to Italian, the output becomes "Lundeì 11 20 Novembre 19", essentially embracing the month with the year.

This output shows up in the preview in wp-admin when changing the format, and in the front end, for example the date display in Twenty Twenty above posts.

The behavior changed with the 5.3 release, and I've so far only had reports and replicated this with Italian, but there may be other strange scenarios with other languages.

Attachments (1)

48606-ordinal-suffix-mandatory-to-decline-month.patch (2.3 KB) - added by Rarst 3 weeks ago.

Download all attachments as: .zip

Change History (12)

This ticket was mentioned in Slack in #polyglots by clorith. View the logs.


3 weeks ago

#2 @Rarst
3 weeks ago

I think this got broken by additions in wp_maybe_decline_date(), [45555]

There was unit test added for Russian with it, so the issue might be it not behaving right with another locale(s).

I didn't write the code, will look into it on fresh head.

Last edited 3 weeks ago by SergeyBiryukov (previous) (diff)

#3 @Rarst
3 weeks ago

Yeah, it's broken in Russian as well.

So we start with "Thursday 14 November 2019" (I'll do this in English for clarity) and have two steps in the logic here:

  1. First we have quick check for non-digits followed by 1-2 digits and optionally ordinal suffix (e.g. Foo 1st, Bar 22nd). In this case this is actually matching "Thursday 14" while we were kinda looking for the month, not day of the week.
  2. We are trying to replace any name of the month, followed by same 1-2 digits + optional suffix by those digits, followed by genitive name of the month. But! Here name of the month followed by 1-2 digits is actually (November 20)19, which replacements turns into '20 November19'

Possible fixes:

  1. Replace if followed by 1-2 digits, but no more digits than that. This would still be wrong if year happens to be represented by 2 digits.
  2. Make ordinal suffix mandatory for replacement and leave it alone otherwise.

Pinging @SergeyBiryukov who wrote original patch for opinion.

Last edited 3 weeks ago by Rarst (previous) (diff)

#4 follow-up: @Rarst
3 weeks ago

  • Keywords has-patch has-unit-tests added

I've added a patch to make ordinal suffix mandatory for replacement and fix outstanding visual error.

In long term we probably need to scrap the whole implementation and write it from scratch. The current one doesn't have access to actual format used and just a pile of wildly guessing regex. I'll make a new ticket for rewrite once we patch specific regression here.

This ticket was mentioned in Slack in #core-datetime by rarst. View the logs.


3 weeks ago

#6 @nielslange
3 weeks ago

#48690 was marked as a duplicate.

#7 @SergeyBiryukov
2 weeks ago

#48741 was marked as a duplicate.

#8 @SergeyBiryukov
11 days ago

  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing

#9 in reply to: ↑ 4 @robydc
10 days ago

Replying to Rarst:

I've added a patch to make ordinal suffix mandatory for replacement and fix outstanding visual error.

In long term we probably need to scrap the whole implementation and write it from scratch. The current one doesn't have access to actual format used and just a pile of wildly guessing regex. I'll make a new ticket for rewrite once we patch specific regression here.

Excuse me, how can I use that patch? I have the same error date display in italian language, what shall i do with that patch?
Thank you.

#10 @Rarst
10 days ago

Excuse me, how can I use that patch? I have the same error date display in italian language, what shall i do with that patch?

This is planned to be included in WordPress version 5.3.1 so everyone will get the fix when it's released.

If you need the fix more urgently you can temporarily switch to a different date format (where month isn't followed by a year) or apply the patch to your copy of core (not generally recommended).

This ticket was mentioned in Slack in #core by audrasjb. View the logs.


30 hours ago

Note: See TracTickets for help on using tickets.