Opened 6 weeks ago
Closed 4 days ago
#64983 closed defect (bug) (fixed)
Scale needs gettext
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 7.0 | Priority: | normal |
| Severity: | normal | Version: | trunk |
| Component: | I18N | Keywords: | has-patch fixed-major dev-reviewed |
| Focuses: | Cc: |
Description
scale is used as a noun and a verb (button)
Change History (20)
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 noesc_html_ex()equivalent, soecho 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()returnsScalein 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
@
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
@
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
@
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
@
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' ); ?>
#9
@
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.
This ticket was mentioned in Slack in #core by audrasjb. View the logs.
12 days ago
#12
@
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
Scaleinsrc/wp-admin/includes/image-edit.phpfile
Trac ticket: #64983
## Use of AI Tools
- None
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