Open Bug 1842814 Opened 1 year ago Updated 3 months ago

"translate" class ignored after seeing "notranslate"

Categories

(Firefox :: Translations, defect, P3)

defect

Tracking

()

People

(Reporter: marco, Unassigned)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

Attached file provatranslate.html

Elements with a notranslate class are ignored by InPageTranslation. Websites like Mastodon also seem to use this to get around issues with Google Translate. However, they also mark elements that they do want translated with a translate class. Firefox Translations ignores that class at the moment.

To Reproduce
Have a page with something like this:
<p class="notranslate">
Könnte es dieses Element bitte ignorieren?
<span>Das wäre toll.</span>
<span class="translate">Aber bitte übersetzen Sie diesen Satz.</span>
</p>

If you translate that page then with Google Chrome, only the last sentence will be translated. If you translate it with Firefox Translations, it doesn't.

Expected behavior
Translate elements that are marked with class="translate" when they appear inside an class="notranslate" or translate="no" element.

Additional context
I haven't been able to find any documentation for Google Translate that says that class="translate" should work. But empirically it does.

The tree walking algorithm will need to be tweaked to continue recursing into elements to search for these elements. Here is one case where the node is determined to not be translatable. Instead of skipping the node, we'll probably need to track that it's parent is not translatable, and continue looking for translatable elements further in.

This should be easily testable by adding a test case similar to this one: https://searchfox.org/mozilla-central/rev/f03ce34731ff8d1f6c77d8241c41d10df13e9aca/toolkit/components/translations/tests/browser/browser_translations_translation_document.js#305-363

The severity field is not set for this bug.
:gregtatum, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(gtatum)
Severity: -- → S3
Flags: needinfo?(gtatum)
Priority: -- → P3

The "official" attribute to use would be translate="no": https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/translate

However, the translate beta does not adhere to it.

(In reply to Jorn from comment #4)

The "official" attribute to use would be translate="no": https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/translate

However, the translate beta does not adhere to it.

Sorry I didn't pay close enough attention. Your bug report is about something else.

Blocks: 1845772
No longer blocks: 1838721
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: