Skip to content

[mirror] dont let browsers auto-translate currency#1

Open
yashwant86 wants to merge 31 commits into
mm-base-62037from
mm-pr-62037
Open

[mirror] dont let browsers auto-translate currency#1
yashwant86 wants to merge 31 commits into
mm-base-62037from
mm-pr-62037

Conversation

@yashwant86
Copy link
Copy Markdown

@yashwant86 yashwant86 commented Apr 26, 2026

Mirror of upstream woocommerce#62037 (open PR live findings) for benchmark. Do not merge.


Summary by MergeMonkey

  • Squashed Bugs:
    • Prevents browser auto-translation of currency symbols by adding translate="no" attribute to price markup across all price display components.
  • Under the Hood:
    • Fixes variable reference bug in ProductCollection Controller pagination logic.
    • Removes obsolete phpstan baseline entries for fixed static analysis warnings.
    • Cleans up trailing whitespace in template files.

masteradhoc and others added 30 commits November 19, 2025 17:12
Fix bug because $parsed_block is out of scope inside function
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@bot-mergemonkey
Copy link
Copy Markdown

bot-mergemonkey Bot commented Apr 26, 2026

Risk AssessmentNEEDS-TESTING · ~15 min review

Focus areas: Price markup translation prevention · ProductCollection Controller operator precedence fix · Test assertion updates for new HTML output

Assessment: Adds translation prevention attributes to all price displays; requires testing across browsers and translation services.

Walkthrough

User views a product price in any WooCommerce price display component (product page, mini-cart, cart, order). The system renders the price HTML with currency symbol wrapped in a span element. With this PR, the span now includes translate="no" attribute, signaling to browser translation engines (Google Translate, etc.) to skip translating the currency symbol, preserving the original currency display.

Changes

Files Summary
Price Markup Translation Prevention
plugins/woocommerce/includes/wc-formatting-functions.php
plugins/woocommerce/client/blocks/assets/js/base/components/product-price/index.tsx
plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/block.tsx
plugins/woocommerce/client/blocks/packages/components/formatted-monetary-amount/index.tsx
packages/js/product-editor/src/components/formatted-price/formatted-price.tsx
plugins/woocommerce/src/Blocks/BlockTypes/MiniCart.php
plugins/woocommerce/src/Blocks/BlockTypes/MiniCartFooterBlock.php
plugins/woocommerce/src/Blocks/BlockTypes/MiniCartProductsTableBlock.php
plugins/woocommerce/client/blocks/assets/js/previews/product-response-items.ts
plugins/woocommerce/client/blocks/assets/js/previews/products.js
Adds translate="no" and notranslate class attributes to currency symbol and price display elements to prevent browser auto-translation engines from modifying currency symbols and amounts.
Test Expectations Update
plugins/woocommerce/tests/legacy/unit-tests/product/data.php
plugins/woocommerce/tests/legacy/unit-tests/formatting/functions.php
plugins/woocommerce/tests/legacy/unit-tests/cart/cart.php
plugins/woocommerce/tests/legacy/unit-tests/order/class-wc-tests-crud-orders.php
Updates test assertions to match new price HTML output with translate="no" attributes on currency symbols.
ProductCollection Controller Logic Fix
plugins/woocommerce/src/Blocks/BlockTypes/ProductCollection/Controller.php
Fixes operator precedence bug by adding parentheses around null coalescing expression before && operator to ensure correct evaluation of forcePageReload flag.
Static Analysis Baseline Cleanup
plugins/woocommerce/phpstan-baseline.neon
Removes obsolete phpstan baseline entries for fixed static analysis warnings in ProductCollection Controller.
Changelog Entries
plugins/woocommerce/changelog/62037-patch-1
packages/js/product-editor/changelog/62037-patch-1
plugins/woocommerce/changelog/patch-1
Adds changelog entries documenting patch fixes for currency translation prevention and variable reference correction.
Whitespace Cleanup
plugins/woocommerce/src/Blocks/BlockTypes/MiniCartProductsTableBlock.php
Removes trailing whitespace from template markup lines.

Sequence Diagram

sequenceDiagram
    participant User
    participant Browser
    participant WooCommerce
    User->>WooCommerce: View product/cart page
    WooCommerce->>WooCommerce: Generate price HTML with translate="no"
    WooCommerce->>Browser: Return HTML with currency symbol marked notranslate
    Browser->>Browser: Parse HTML, detect translate="no" attribute
    User->>Browser: Enable auto-translate (e.g., Google Translate)
    Browser->>Browser: Skip translating currency symbol
    Browser->>User: Display price with original currency symbol intact
Loading

Dig Deeper With Commands

  • /review <file-path> <function-optional>
  • /chat <file-path> "<question>"
  • /roast <file-path>

Runs only when explicitly triggered.

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.

7 participants