Skip to content

I18N: Add translator context to "Scale" strings in image editor#11405

Open
sanketio wants to merge 1 commit intoWordPress:trunkfrom
sanketio:fix/64983
Open

I18N: Add translator context to "Scale" strings in image editor#11405
sanketio wants to merge 1 commit intoWordPress:trunkfrom
sanketio:fix/64983

Conversation

@sanketio
Copy link
Copy Markdown

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 Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@github-actions
Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props sanketparmar.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions
Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant