Run language detection on nodes that have larger amounts of text content
Categories
(Firefox :: Translations, enhancement)
Tracking
()
People
(Reporter: nordzilla, Unassigned)
References
Details
Attachments
(1 file, 1 external file)
|
6.67 KB,
text/html
|
Details |
Description
Note: This idea was originally pitched in order to improve the experience translating https://www.wiwi.blog/blog/cn-domain-scam/ from Traditional Chinese into English.
In general, our models are trained to try to pass through text that is not the intended language. That is, if our French-to-English (fr_en) model were to encounter the Spanish text, "Hola, ¿cómo estás?" then it is trained to pass that text through and not attempt to translate it.
You can see an example of this on the about:translations page in Firefox.
about:translations#src=fr&trg=en&text=Hola%2C+%C2%BFc%C3%B3mo+est%C3%A1s%3F
This short Spanish phase is correctly passed through.
But our Translation models can never be 100% perfect in all situations. They are necessarily a statistical solution that attempts to solve exact problems; therefore there certainly exist some non-French phrases that will not be correctly passed through untouched by our French-to-English model.
Take, for example, this Spanish phrase: "Creo que es interesante que, aunque el logotipo de Firefox parece un zorro, el nombre «firefox» se asocia más comúnmente con el panda rojo."
about:translations#src=fr&trg=en&text=Creo+que+es+interesante+que%2C+aunque+el+logotipo+de+Firefox+parece+un+zorro%2C+el+nombre+%C2%ABfirefox%C2%BB+se+asocia+m%C3%A1s+com%C3%BAnmente+con+el+panda+rojo.
Our French-to-English model does not correctly ignore and pass through the entire sentence. Instead, we end up with some mixture of half-translated text that the model attempted to treat as French: "Creo que est interestsante that, as the logotipo of Firefox bears a zorro, the number "firefox" is asocia más comúnmente con el panda rojo."
We may be able to do a better job here, algorithmically, when a user requests translation on a page that has text in multiple languages.
We have some statistical data that is already cited in the code regarding the accuracy of our language detection base don the length of the text.
We should follow the same rule here: if the node's text content is greater than or equal to 150 UTF-16 code units, then we should consider running the language detection for that node, to determine the node's language. If we get a strong signal that it is not in the language we are attempting to translate, then we can ignore the text.
I am marking this as a "Good Next Bug" because, while the changes to the code should be fairly self-contained and easily testable, this will require some investigation into using the Firefox profiler to determine the performance impact of running language detection in situations where we previously did not. We will also have to do some amount of qualitative human analysis to make sure that we're not unintentionally skipping content that should be translated due to incorrect language detection.
The bulk of the changes will lie in the translations-document.sys.mjs file.
I've also attached a test page that may be useful as a quick manual test during implementation for whoever takes this bug (generated from this description by an LLM).
| Reporter | ||
Updated•6 months ago
|
Hi, I would like to work on this bug. Could you please assign it to me?
| Reporter | ||
Comment 2•5 months ago
|
||
Hi Sidh Jain, you are welcome to submit a patch without being assigned.
Comment 3•2 months ago
|
||
| Reporter | ||
Comment 4•1 month ago
|
||
I don't feel that I currently have time to mentor this bug, compared to when I filed it. And this was only ever an exploratory initiative, which does make it harder to give someone a deterministically successful experience.
Caleb Pickard, I only just now saw that you had submitted a WIP patch when I opened this bug to write this comment. We aren't notified when patches get submitted as "WIP," which is why I didn't see it. I apologize for the experience you must have had here with this.
In the future, please don't be afraid to use Bugzilla's "Request information from" functionality at the bottom.
Description
•