Make WordPress Core

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#48606 closed defect (bug) (fixed)

Some date formats get incorrectly output in Italian

Reported by: clorith's profile Clorith Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 5.3.1 Priority: normal
Severity: normal Version: 5.3
Component: Date/Time Keywords: has-patch has-unit-tests
Focuses: Cc:

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 5 years ago.

Download all attachments as: .zip

Change History (16)

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


5 years ago

#2 @Rarst
5 years 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 5 years ago by SergeyBiryukov (previous) (diff)

#3 @Rarst
5 years 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 5 years ago by Rarst (previous) (diff)

#4 follow-up: @Rarst
5 years 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.


5 years ago

#6 @nielslange
5 years ago

#48690 was marked as a duplicate.

#7 @SergeyBiryukov
5 years ago

#48741 was marked as a duplicate.

#8 @SergeyBiryukov
5 years ago

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

#9 in reply to: ↑ 4 @robydc
5 years 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
5 years 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.


5 years ago

#12 @SergeyBiryukov
5 years ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 46862:

Date/Time: When determining whether to decline the month name in wp_maybe_decline_date(), take word boundaries into account.

Add more unit tests.

Props Rarst, Clorith, timon33, Xendo, SergeyBiryukov.
Fixes #48606.

#13 @SergeyBiryukov
5 years ago

In 46863:

Date/Time: When determining whether to decline the month name in wp_maybe_decline_date(), take word boundaries into account.

Add more unit tests.

Props Rarst, Clorith, timon33, Xendo, SergeyBiryukov.
Merges [46862] to the 5.3 branch.
Fixes #48606.

#14 follow-up: @Rarst
5 years ago

I am not sure this is sufficient solution long term, since underlying ambiguity is not resolved.

For example Январь 19 ("January 19" in Russian) is assumed to be 19th day of January and declined, while it might be 19th year (as in 2019) and shouldn't be.

It is impossible to distinguish meaning of arbitrary digits and string, without knowing underlying format or having them disambiguated by ordinal suffix.

Version 0, edited 5 years ago by Rarst (next)

#15 in reply to: ↑ 14 @SergeyBiryukov
5 years ago

Replying to Rarst:

I am not sure this is sufficient solution long term, since underlying ambiguity is not resolved.

Yes, I agree it's not a comprehensive solution :)

FWIW, Italian doesn't seem to decline month names, so turning on the setting for that language appears to be a translator's mistake.

[46862] is just an attempt to address the regression without introducing new regressions in languages that do use month declensions, which would somewhat defeat the purpose of the function.

For example Январь 19 ("January 19" in Russian) is assumed to be 19th day of January and declined, while it might be 19th year (as in 2019) and shouldn't be.

Right, however the latter is far less common from my experience, I'd call that an acceptable edge case for now.

It is impossible to distinguish meaning of arbitrary digits in a string, without knowing underlying format or having them disambiguated by ordinal suffix.

Indeed, I'm open to rewriting the current implementation from scratch in a future release, as you've suggested in comment:4.

Note: See TracTickets for help on using tickets.