Make WordPress Core

Opened 6 weeks ago

Closed 4 days ago

#64983 closed defect (bug) (fixed)

Scale needs gettext

Reported by: timse201's profile timse201 Owned by: audrasjb's profile audrasjb
Milestone: 7.0 Priority: normal
Severity: normal Version: trunk
Component: I18N Keywords: has-patch fixed-major dev-reviewed
Focuses: Cc:

Change History (20)

#1 @audrasjb
6 weeks ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to 7.0

To be clear, what is needed here is a context for translators, using the _x() function.
See https://developer.wordpress.org/plugins/internationalization/how-to-internationalize-your-plugin/#disambiguation-by-context

This ticket was mentioned in PR #11405 on WordPress/wordpress-develop by @sanket.parmar.


6 weeks ago
#2

  • Keywords has-patch added; needs-patch removed

## Summary

The word "Scale" appears twice in wp-admin/includes/image-edit.php with two distinct grammatical roles but both used the same esc_html_e( 'Scale' ) call with no translator context. In many languages (e.g. German: *Skalierung* vs. *Skalieren*), a noun and a verb require different translations, so translators were forced to pick one form for both usages.

## Changes

File: src/wp-admin/includes/image-edit.php

Replaced both esc_html_e( 'Scale' ) calls with echo esc_html_x() to preserve HTML escaping while adding disambiguating context:

Location Role New call
Toolbar toggle button Noun — panel section label echo esc_html_x( 'Scale', 'noun: label for the image scale controls panel', 'default' )
Primary action button Verb — executes the scaling echo esc_html_x( 'Scale', 'verb: button to apply image scaling', 'default' )

Note: esc_html_e() echoes directly. WordPress core has no esc_html_ex() equivalent, so echo esc_html_x() is the correct pattern to preserve both HTML escaping and add translator context.

## Testing

  • No existing tests required updating. The only test file covering this area (`tests/phpunit/tests/ajax/wpAjaxImageEditor.php`) tests PHP save/restore logic, not HTML template output.
  • English output is unchanged — esc_html_x() returns Scale in English exactly as before.

---

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

---

## Use of AI Tools

AI assistance: Yes
Tool(s): GitHub Copilot
Model(s): Claude Sonnet 4.6
Used for: Identifying affected code locations and composing the fix; final implementation was reviewed and edited by me.

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


6 weeks ago

#4 @audrasjb
6 weeks ago

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

We usually only add noun or verb in the _x() context, but why not making in more verbose? LGTM.

#5 @audrasjb
6 weeks ago

  • Keywords commit added

Also the third parameter of the function is useless @sanketparmar, I fixing your proposal directly in the commit.

#6 @audrasjb
6 weeks ago

  • Keywords changes-requested added; commit removed

Well Im' removing commit as this also need to be fixed on Gutenberg side on GitHub.
Adding changes-requested.

#7 @sabernhardt
6 weeks ago

I disagree that [55919] intended "Scale" as a noun for the toggle button in the media library. It was button text next to the number inputs first, and the English verb fits both buttons.

However, adding context is still helpful because some translations used a word for "Apply", which does not fit both buttons. Maybe the toggle button's context could be something like
<?php echo esc_html_x( 'Scale', 'verb: button to expand the image scaling controls' ); ?>

#8 @sabernhardt
6 weeks ago

GB76917 is a PR for the Gutenberg string(s).

#9 @timse201
6 weeks ago

We shouldn't overload our translation file. I think it's enough to add a context such as verb, noun or heading, button. Strings with the same context will be shown as a single string in GlotPress.
New locales will be thankful.

Last edited 6 weeks ago by timse201 (previous) (diff)

#10 @timse201
6 weeks ago

Too many requests. I will have a look later.

Last edited 6 weeks ago by timse201 (previous) (diff)

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


12 days ago

#12 @audrasjb
12 days ago

  • Keywords needs-patch added; has-patch removed

We need a new PR with updated context: verb or noun (or button for example) is enough, translators don't need more details.

New (or updated) patch welcome :)

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


12 days ago
#13

  • Keywords has-patch added; needs-patch removed
  • Added Translator Context for Scale in src/wp-admin/includes/image-edit.php file

Trac ticket: #64983

## Use of AI Tools

  • None

#14 @shailu25
12 days ago

Created New PR 11679 to add context for Scale.

#15 @shailu25
10 days ago

  • Keywords changes-requested removed

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


5 days ago

#17 @jorbin
5 days ago

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

In 62312:

I18N: Add translator context to scale strings in image editor

Props shailu25, audrasjb, timse201, sanketparmar.
Fixes #64983.

#18 @jorbin
5 days ago

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

Reopening back backport consideration.

Also noting that the GB related change has not been merged. I added that to the 7.0 project board.

#19 @audrasjb
4 days ago

  • Keywords dev-reviewed added; dev-feedback removed

Marking as reviewed.

#20 @audrasjb
4 days ago

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

In 62315:

I18N: Add translator context to scale strings in image editor.

Reviewed by jorbin, audrasjb.
Merges [62312] to the 7.0 branch.
Props shailu25, audrasjb, timse201, sanketparmar.
Fixes #64983.

Note: See TracTickets for help on using tickets.