Open Bug 2026738 Opened 7 months ago Updated 16 days ago

Run language detection on node subtrees that have a lang attribute

Categories

(Firefox :: Translations, enhancement)

enhancement

Tracking

()

People

(Reporter: nordzilla, Unassigned, Mentored)

References

Details

(Keywords: good-first-bug)

Attachments

(1 file, 2 external files)

Attached file example.html —

Description

In Bug 2025131, a user reported an issue that https://learn.microsoft.com/en-us/archive/blogs/technet/itasupport/sendsas-step-by-step contains Italian text within DOM nodes that declare the attribute lang=en-us.

While this is currently expected behavior in Firefox to trust the lang attribute (the website itself is configured incorrectly), perhaps we could do a better job of running our language detector on nodes that have these attributes to get a second opinion.

We already do some double checking if the lang attribute is on the top-level <html> tag. We likely could extend this to check other nodes more specifically.

I think this would be a great first bug for a new contributor, so I am marking it as such. I am happy to mentor anyone who would like to give this a try.


Expectations

When we open a web page in Firefox, we determine the language of the entire page.

As we parse through the document to find translatable nodes, we may encounter a specific node that has a lang attribute on it.

We should update Firefox to perform the following logic:

  1. Does the node's lang tag match the document's lang tag? If so, go ahead and translate it. (We already do this).
  2. Does the node's lang tag differ from the document's lang tag? If so, run the language detector on the node's text content.
    2a. Does the detected language match the node's lang tag? If so, skip this node.
    2b. Does the detected language match the document's lang tag? If so, queue this node to be translated.

There are a few other aspects that we should consider with regard to the length of the node's text content. The shorter the text is, the less accurate the language detector's results are. So we won't always be able to fully trust the language detector if the node itself has only a single word.

I haven't decided how we want to handle this yet, but we can work out the details when a contributor takes this bug.


Note: I've attached a simple HTML test page that reproduces the same issue, in case the originally reported Microsoft link above gets fixed.

Duplicate of this bug: 2025131

Hi, Erik!
I like to solve this one, Can you please guide me, so that we can start working on it.
Thank You!

Hi Erik,
I would like to work on this bug if it's available. I'm familiar with this bug

Hi,

Yes, any new contributor is welcome to work on this.

I didn't expect to get so much activity all at once. I can only review an accept one patch to land.

ROSHAAN, I've written a fairly detailed "Expectations" section in the main comment. Did you have any specific questions?

Pranjali, it seems that you expressed interest in a different "Good First Bug" that I filed. You're welcome to look at this one, but it would be best to only look at one at a time.

I agree, first I’ll continue with the one I initially picked and come back to this one later if it’s still available.
Really appreciate the guidance

Duplicate of this bug: 1910486
See Also: → 2033067

Hey Erik,
I'm a new contributor, and I'll be submitting a patch for this soon.

Assignee: nobody → kesslermentele
Status: NEW → ASSIGNED

This good-first-bug hasn't had any activity for 2 months, it is automatically unassigned.
For more information, please visit BugBot documentation.

Assignee: kesslermentele → nobody
Status: ASSIGNED → NEW
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: