Closed Bug 1843914 Opened 2 years ago Closed 1 year ago

Inline paragraphs are not translated by Bergamot when they're the minority

Categories

(Firefox :: Translations, defect, P3)

Firefox 115
defect

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: cvqvxrdvfg, Unassigned)

References

Details

Steps to reproduce:

Translate https://baginett.blogspot.com/2023/05/18280-24-2023.html from Russian to English.

Actual results:

Most of the paragraphs get translated, because most are wrapped in a <p> tag.

However some paragraphs such as 'А вот и прижизненные фото СРК "Иван Хурс".' are not wrapped in a <p> and therefore remain untranslated.

The parent element of both kinds of paragraph is a <div> where Bergamot sets x-bergamot-translated="skipped does-not-have-text-of-its-own", because there are more <p> tags than bare text nodes.

Expected results:

All text nodes should have been translated.

I took a look at InPageTranslation.js and my understanding is that when processing the big <div> node:

  1. hasInlineContent(node) returns false when inlineElements < blockElements.
  2. Therefore in that case validateNode() returns NodeFilter.FILTER_SKIP and sets "does-not-have-text-of-its-own".
  3. Therefore the tree walker gets called, and it seems that when this is the case bare text nodes fail to get translated.

I'm not sure if step 1 or step 3 is to blame, but the end result is that if the <div> has both inline and block elements then inline elements will only be translated if they're not in the minority.

Minimal testcase, to be translated from English to any language:

<div>
Inline paragraph won't be translated unless you remove a block paragraph or add another inline element at the end of the div.
<p>Block paragraph will always be translated.</p>
<p>Block paragraph will always be translated.</p>
</div>

Component: Untriaged → Translation
Version: Firefox 114 → Firefox 115

I think this report is for the addon, but it will most likely reproduce in Firefox's port of the code. This would be fixed by Bug 1837424. I haven't verified the behavior since it seems like a reasonable thing to be happening given the implementation.

This will be a good test case to verify after Bug 1837424 is fixed.

Severity: -- → S3
Depends on: 1837424
Priority: -- → P3

I've reproduced this issue in the latest Nightly 118.0a1 version on Windows 10 x64.
Setting as NEW.

Status: UNCONFIRMED → NEW
Ever confirmed: true

I don't reproduce in Nightly anymore, and the specific case I have as a test in Bug 1837424, which fixes the underlying issue here.

Status: NEW → RESOLVED
Closed: 1 year ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.