Skip to content

Text inside open shadow roots is not detected/translated #612

Description

@workfriend

Hi!

I have a problem when attempting to translate certain Yahoo Auctions listings. This is an example of where I experience this problem:
https://auctions.yahoo.co.jp/jp/auction/v1232293300

It appears that Linguist does not translate text nodes that live inside an open shadow root. The element itself is reachable (element.shadowRoot returns the ShadowRoot, confirming mode: "open"), but the page-scan/translation logic appears to only walk the light DOM and never recurses into element.shadowRoot for child elements.

To reproduce this issue:

  1. Visit a Yahoo Auctions Japan listing such as https://auctions.yahoo.co.jp/jp/auction/v1232293300 -- Note that there are some generic unstyled auction listings that are easily translated through Linguist. This seems to be listings with sellers' free-text descriptions with specific styling or something.
  2. Using Linguist, trigger full-page translation.
  3. The translation does not take effect, and the seller's item-description block (under the "商品説明" heading) is never translated — it remains in Japanese.

Analysis
I wanted to confirm that it's a shadow DOM issue specifically rather than being a selector/exclude-list issue that is configured in my Linguist settings. To do so, on this page, I ran some JS in the console to confirm:

Firstly, confirm shadowRoot's presence in the div:

[...document.querySelectorAll('*')].filter(el => el.shadowRoot)
// → [div]  (one element, open shadow root)

I then confirmed whether the text can be found, which is where the original, untouched text resides:

[...document.querySelectorAll('*')].filter(el => el.shadowRoot)[0].shadowRoot.textContent
// → returns the full untranslated Japanese description text

Here is a screenshot of running this:

Image

So as seen in the screenshot, what we can see here is that the original text exists, and is contained in an open (not closed) shadow root, and is reachable via standard DOM APIs from a content script but Linguist's translator never reaches it.

The text outside of this section is translated fine as seen in the attached screenshot (section highlighted in blue):

Image

What's also strange is that partial translated text trails this section in the HTML--not sure if this is an attempt made by linguist, but this never gets rendered on the page as seen in the following image:
Image

Expected Behavior
Linguist should recurse into open shadow roots the same way it walks regular child elements, applying the same translatable/exclude-list logic inside them.

Environment
macOS Tahoe 26.5.1
Firefox 152.0.3 (aarch64)

Any help would be appreciated!

Cheers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingimportantMust do it

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions