Make WordPress Core

Opened 4 weeks ago

Closed 3 weeks ago

Last modified 3 weeks ago

#62402 closed defect (bug) (fixed)

Untranslatable texts in admin nav-menu.js

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

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
4 weeks ago

  • Focuses administration coding-standards removed
  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to 6.7.1

cc @joedolson

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


4 weeks 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
4 weeks ago

  • Owner set to joedolson
  • Status changed from new to accepted

#4 @SergeyBiryukov
4 weeks ago

  • Description modified (diff)

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


4 weeks ago

#6 @desrosj
4 weeks 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.

Last edited 4 weeks ago by desrosj (previous) (diff)

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


4 weeks ago

#8 follow-up: @tobifjellner
4 weeks 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
4 weeks ago

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

Last edited 4 weeks ago by audrasjb (previous) (diff)

#10 in reply to: ↑ 8 @SergeyBiryukov
4 weeks 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:


3 weeks 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:


3 weeks ago
#12

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

@yogeshbhutkar commented on PR #7788:


3 weeks ago
#13

Thanks, @desrosj.

The changes are appended to the PR.

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


3 weeks ago

#15 @joedolson
3 weeks ago

  • Keywords commit added

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

#16 @joedolson
3 weeks ago

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

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
3 weeks ago

  • Keywords dev-feedback fixed-major added
  • Resolution fixed deleted
  • Status changed from closed to reopened

Re-opening for dev review and commit to 6.7.1.

#18 @desrosj
3 weeks ago

  • Keywords dev-reviewed added; dev-feedback removed

Thanks @joedolson. Looks good to backport.

#19 @desrosj
3 weeks ago

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

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
3 weeks 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
3 weeks ago

  • Keywords dev-feedback added; dev-reviewed removed
  • Resolution fixed deleted
  • Status changed from closed to reopened

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

#22 @desrosj
3 weeks ago

  • Keywords dev-reviewed added; dev-feedback removed

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

#23 @desrosj
3 weeks ago

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

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.