Closed Bug 1897482 Opened 9 months ago Closed 9 months ago

TranslationsParent.isSupportedAsToLang checks the wrong language

Categories

(Firefox :: Translations, defect, P3)

defect

Tracking

()

RESOLVED FIXED
128 Branch
Tracking Status
firefox-esr115 --- unaffected
firefox126 --- wontfix
firefox127 --- wontfix
firefox128 --- fixed

People

(Reporter: nordzilla, Assigned: nordzilla)

References

(Regression)

Details

(Keywords: regression)

Attachments

(2 files)

Attached image finnish-example.png

Description

When testing the localized versions of the SelectTranslationsPanel, I noticed that languages for which we only offer translations as a source language were being offered as a target language. At the time of writing, this occurred with Finnish, which we currently only support as a source language.

This leads to an error state when the panel opens, since Finnish cannot be found as a valid target language (see attached screenshot).

This is caused by an unfortunate typo that I made, where the isSupportedAsToLang() function checks the fromLang value instead of the toLang value.

Thankfully, the SelectTranslationsPanel is currently the only consumer of this function call, and this fix should not require any uplifting because it will be corrected before the SelectTranslationsPanel release.


Steps to reproduce

  1. Download the Finnish version of Firefox Nightly.
  2. Open the Finnish nightly and navigate to a non-Finnish page in a translatable language, e.g. https://es.wikipedia.org.
  3. Select some text and open the right-click context menu.

Expected Behavior
Translation to Finnish should not be offered as it is not yet supported as a target language.

Actual Behavior
Translation to Finnish is offered, and when clicked, it leads to a panel error state with a blank to-language selection.

Set release status flags based on info from the regressing bug 1870327

The TranslationsParent.isSupportedAsToLang() function was
unintentionally checking the list of from-languages.
This patch fixes the function to check the correct languages.

Attachment #9402497 - Attachment description: WIP: Bug 1897482 - Fix TranslationsParent.isSupportedAsToLang r=#translations-reviewers! → Bug 1897482 - Fix TranslationsParent.isSupportedAsToLang r=#translations-reviewers!
Severity: -- → S3
Priority: -- → P3

Erik, can you request uplift to beta if you feel it is not too risky? Thanks!

Flags: needinfo?(enordin)

Hey Liz,

I don't think this needs to be uplifted.

At the time of writing, the only consumer of this code currently is the SelectTranslationsPanel feature, which is preffed off for the Firefox 127 release build, and is targeted for release in Firefox 128.


Searchfox Regex Query: (isSupportedAsToLang|GetTopPreferredSupportedToLang)

Core code (5 lines across 2 files)
	
Textual Occurrences (5 lines across 2 files)

browser/components/translations/content/selectTranslationsPanel.js
330	TranslationsParent.getTopPreferredSupportedToLang(),
366	: await TranslationsParent.isSupportedAsToLang(langTag);

toolkit/components/translations/actors/TranslationsParent.sys.mjs
2234	static async isSupportedAsToLang(langTag) {
2246	static async getTopPreferredSupportedToLang() {
2248	async langTag => await TranslationsParent.isSupportedAsToLang(langTag)

The defect is technically present in Firefox 126 and 127, but nothing is using this API surface.

That being said, this is a very low-risk change and I can uplift it if still desired.

Flags: needinfo?(enordin) → needinfo?(ehenry)

Ok, thanks for the background, that makes sense!

Flags: needinfo?(ehenry)
Pushed by enordin@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/95291aa6a751 Fix TranslationsParent.isSupportedAsToLang r=translations-reviewers,gregtatum
Status: NEW → RESOLVED
Closed: 9 months ago
Resolution: --- → FIXED
Target Milestone: --- → 128 Branch
QA Whiteboard: [qa-128b-p2]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: