Make WordPress Core

Opened 8 months ago

Closed 8 months ago

Last modified 8 months ago

#59219 closed defect (bug) (fixed)

Output of JS version of human_time_diff in the editor is not translated

Reported by: ramonopoly's profile ramonopoly Owned by: audrasjb's profile audrasjb
Milestone: 6.4 Priority: normal
Severity: normal Version: 6.3
Component: Editor Keywords: has-patch gutenberg-merge commit
Focuses: Cc:

Description

Currently the output of humanTimeDiff() in the editor is not translatable as it expects translated strings to pass to moment.js.

These strings must be passed in the relative object as per the moment.js locale settings model.

We need to update wp_default_packages_inline_scripts() to add relative time strings to the wp-date inline script.

Gutenberg PR: https://github.com/WordPress/gutenberg/pull/53931

Props to @oandregal for the original report: https://github.com/WordPress/gutenberg/issues/53888

Change History (7)

This ticket was mentioned in PR #5101 on WordPress/wordpress-develop by @ramonopoly.


8 months ago
#1

This PR syncs the changes in:

Updates wp_default_packages_inline_scripts() to add relative time strings to the wp-date inline script.

This is so the JS version of human_time_diff can output translated strings.

It uses these translated strings in moment calculations. See the relevant model: https://momentjscom.readthedocs.io/en/latest/moment/07-customization/07-relative-time/

Trac ticket: https://core.trac.wordpress.org/ticket/59219

#2 @audrasjb
8 months ago

  • Keywords commit added; i18n-change removed
  • Owner set to audrasjb
  • Status changed from new to accepted
  • Version changed from trunk to 6.3

Thanks for the ticket and patch!
Marking for commit consideration.

Ps: removing i18n-change as this is only used late in the development cycle (after string freeze) to track potential string changes, as translators need to be notified.

@swissspidy commented on PR #5101:


8 months ago
#3

Doesn't this also partially address https://core.trac.wordpress.org/ticket/47373?

What I don't understand is why this was first addressed in Gutenberg and not just directly in core 🤷 Seems like unnecessary duplicate work.

#4 @swissspidy
8 months ago

Looks like a duplicate of #47373

@oandregal commented on PR #5101:


8 months ago
#5

Doesn't this also partially address https://core.trac.wordpress.org/ticket/47373?

Oh, I wasn't aware of it. Thanks for sharing. I see the ticket is 4 years old, so thank you, @ramonjd, for addressing it! :)

What I don't understand is why this was first addressed in Gutenberg and not just directly in core 🤷 Seems like unnecessary duplicate work.

I already commented here, though it's perhaps worth re-sharing:

Gutenberg supports the last two WordPress releases. At the moment, WordPress 6.2 and WordPress 6.3. Even when/if the fix is released as part of WordPress 6.4, Gutenberg still has to support WordPress 6.3. I think it's worth enabling users to see the string in their language faster than 6.4 is available (and before they update).

#6 @audrasjb
8 months ago

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

In 56496:

Editor: Add relative time strings for the wp-date inline script output.

This changeset updates wp_default_packages_inline_scripts() to add relative time strings to the wp-date inline script, so the JS version of human_time_diff
can output translated strings.

Props ramonopoly, oandregal, swissspidy, manzoorwanijk, adrianduffell, Presskopp.
Fixes #59219, #47373.

Note: See TracTickets for help on using tickets.