Make WordPress Core

Opened 22 months ago

Closed 22 months ago

Last modified 22 months ago

#62402 closed defect (bug) (fixed)

Untranslatable texts in admin nav-menu.js

Reported by: juliemoynat Owned by: joedolson
Priority: normal Milestone: 6.7.1
Component: Menus Version:
Severity: normal Keywords: has-patch commit fixed-major dev-reviewed
Cc: Focuses: javascript

Description (last modified by SergeyBiryukov)

In WordPress 6.7, this ticket #43305 has been fixed. Two select fields have been added in the "Appearance > Menus" admin page.

In these select fields, there are options with English words that are added in "wp-admin\js\nav-menu.js":

  • "No Parent"
  • "of" (for "1 of 5")

They are raw texts and not translatable strings.

Change History (24)

#1 @swissspidy
22 months ago

  • Focuses administration coding-standards removed
  • Keywords needs-patch added
  • Milestone Awaiting Review6.7.1

cc @joedolson

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


22 months ago
#2

  • Keywords has-patch added; needs-patch removed

### Description
Updated raw strings to use i18n functions.

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

#3 @joedolson
22 months ago

  • Owner set to joedolson
  • Status newaccepted

#4 @SergeyBiryukov
22 months ago

  • Description modified (diff)

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


22 months ago

#6 @desrosj
22 months ago

Added a review on the PR, but it seems that two of the strings should maybe use wp.i18n._x instead of wp.i18n. to provide additional context to translators? It may not be clear what is being translated.

Version 0, edited 22 months ago by desrosj (next)

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


22 months ago

#8 follow-up: @tobifjellner
22 months ago

_x() may not be needed, IF:

  1. The string is only used once (or in the same way wherever it occurs), and
  2. adding a Translators: comment works.

Strings like "x of y", is usually best to build with fprint(), if possible. And still with a clarifying comment.

#9 @audrasjb
22 months ago

_x is effectively needed if we can't add a translator comment, which is probably the case, here.

Last edited 22 months ago by audrasjb (previous) (diff)

#10 in reply to: ↑ 8 @SergeyBiryukov
22 months ago

Replying to tobifjellner:

Strings like "x of y", is usually best to build with fprint(), if possible.

Indeed, wp.i18n.sprintf() should be used there.

@yogeshbhutkar commented on PR #7788:


22 months ago
#11

Thanks, @desrosj for suggesting an improvement here.

Sure, it would be better to provide context to the translator. I've added a patch for the same. Thanks.

@desrosj commented on PR #7788:


22 months ago
#12

@yogeshbhutkar one more change! @SergeyBiryukov confirmed in track that wp.i18n.sprintf() is actually the correct function.

@yogeshbhutkar commented on PR #7788:


22 months ago
#13

Thanks, @desrosj.

The changes are appended to the PR.

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


22 months ago

#15 @joedolson
22 months ago

  • Keywords commit added

I made a minor change for readability, but I think this is good to go.

#16 @joedolson
22 months ago

  • Resolutionfixed
  • Status acceptedclosed

In 59426:

Menus: i18n: Fix untranslatable strings in nav-menu.js.

Wrap three untranslatable strings in nav menus in JS translation functions.

Follow up to [59265].

Props juliemoynat, swissspidy, yogeshbhutkar, sergeybiryukov, desrosj, tobifjellner, audrasjb, joedolson.
Fixes #62402.

#17 @joedolson
22 months ago

  • Keywords dev-feedback fixed-major added
  • Resolution fixed
  • Status closedreopened

Re-opening for dev review and commit to 6.7.1.

#18 @desrosj
22 months ago

  • Keywords dev-reviewed added; dev-feedback removed

Thanks @joedolson. Looks good to backport.

#19 @desrosj
22 months ago

  • Resolutionfixed
  • Status reopenedclosed

In 59428:

Menus: i18n: Fix untranslatable strings in nav-menu.js.

Wrap three untranslatable strings in nav menus in JS translation functions.

Follow up to [59265].

Reviewed by desrosj, joedolson.
Merges 59426 to the 6.7 branch.

Props juliemoynat, swissspidy, yogeshbhutkar, sergeybiryukov, desrosj, tobifjellner, audrasjb, joedolson.
Fixes #62402.

#20 @SergeyBiryukov
22 months ago

In 59431:

I18N: Adjust translator comments in nav-menu.js.

Includes:

  • Moving the comments directly above wp.i18n._x() so that they can be picked up properly.
  • Simplifying the context to avoid unnecessarily translating the string twice for the same use case.
  • Using the established translator comments format for consistency.

Follow-up to [59428].

See #62402.

#21 @SergeyBiryukov
22 months ago

  • Keywords dev-feedback added; dev-reviewed removed
  • Resolution fixed
  • Status closedreopened

Just some minor cleanup for translator comments in [59431], reopening for a second committer's review.

#22 @desrosj
22 months ago

  • Keywords dev-reviewed added; dev-feedback removed

Thank you, @SergeyBiryukov! Looks good. Backporting now.

#23 @desrosj
22 months ago

  • Resolutionfixed
  • Status reopenedclosed

In 59432:

I18N: Adjust translator comments in nav-menu.js.

Includes:

  • Moving the comments directly above wp.i18n._x() so that they can be picked up properly.
  • Simplifying the context to avoid unnecessarily translating the string twice for the same use case.
  • Using the established translator comments format for consistency.

Follow-up to [59428].

Reviewed by SergeyBiryukov, desrosj.
Merges [59431 to the 6.7 branch.

Fixes #62402.

Note: See TracTickets for help on using tickets.