VOOZH about

URL: https://bugzilla.mozilla.org/2031015

⇱ 2031015 - Suggest the default target language for translation after changing the detected source language


Closed Bug 2031015 Opened 2 months ago Closed 1 month ago

Suggest the default target language for translation after changing the detected source language

Suggest the default target language for translation after changing the detected source language
Firefox
Translations
Firefox 149
All
All
enhancement
Points:
---
RESOLVED FIXED
RESOLVED
FIXED
152 Branch
Iteration:
---
a11y-review
Accessibility Severity
Performance Impact
Webcompat Priority
Webcompat Score
Tracking Status
firefox152 --- fixed
Tracking Status
relnote-firefox
firefox-esr115
firefox-esr140
firefox-esr153
firefox152
firefox153
firefox154
---
QA Whiteboard:
[qa-triage-done-c153/b152]
Has STR:
---
Change Request:
---
Bug Flags:
Signature:
None
This bug is publicly visible.

 
Reporter

Description

2 months ago

I am an English speaker. I frequently encounter the situation where either a page's language is misdetected as English, or there is a majority-English page that has a portion in a foreign language that I would like to translate (for example, a post from a foreign user on a social media site that presents its surrounding UI to me in English). I can manually bring up the "Translate page..." dialog with the hamburger menu, which then shows me:

Translate from
--English
Translate to
--Choose a language

I have to select the "Translate from" language myself which is fair enough. But every single time I also have to pick English as the "Translate to" language, even though I only ever translate into English, and Firefox knows to give me English as the default "Translate to" language when the page is detected as non-English.

Based on bug 1995247 comment #2, this is happening because Firefox is trying to avoid suggesting English to English which would be useless. That's understandable, but I think it's possible to do better here. Something like the following logic:

When the user changes the "Translate from" selection
If "Translate to" is not set (i.e. still showing "Choose a language")
AND the new "Translate from" language is not the same as the default "Translate to" language
Then set the "Translate to" selection to the profile's default

This would solve my use case while not causing any new problems that I can think of. At worst, the user might need to select a different "Translate to" language, but they would be no worse off than with the current behaviour of always showing "Choose a language".

Attached image image.pngDetails

Hi Justin, I appreciate you filing this.

I read through your logic and reasoning here, and I agree that I think this would be an improved experience within the Full-Page Translations Panel.

As a software developer, it's not always clear to me what minor pain points exist for users, so feedback like this is really helpful.

The actual implementation of this shouldn't be too involved, so I am going to mark this as a "Good First Bug" and assign myself as a mentor.

If you, yourself, would like to try working on this, I'd be more than happy to try to help point you in the right direction.


In the meantime, I want to take this opportunity to make sure that you are aware of some of our other Translations features within Firefox that may be helpful here. I've attached a screenshot demonstrating them.

In the screenshot, I've opened up a Spanish dictionary website, creating a situation where the website itself is in English, but has Spanish content in various places.

Firstly, you can utilize Firefox's brand-new Split View capabilities to open the about:translations page, effectively creating a live-translation companion in which to paste any non-English content from the web page. This is shown on the left side of the screenshot.

Secondly, we also have the Select Translations Panel, which is accessible by highlighting a selection of text, right clicking, and selecting the context menu item for translating the selection. This is shown toward the bottom center of the screenshot. The Select Translations Panel also has the "Translate full page" button which will trigger the in-page translations with the currently selected language pair, if you want to move forward with actually translating the page's content directly.

Mentor: enordin
Keywords: good-first-bug
Reporter

Comment 2

2 months ago

Thanks, I was not aware of the context menu item for translating a selection, that takes care of a lot of the situations where this issue arises and is definitely something I'll be using a lot going forward.

As far as working on the issue myself, it hadn't occurred to me but I am a developer in my day job so I guess it's a fair suggestion. :)
If you could point to the general vicinity of the codebase to look at, I can take a peek. I'm pretty busy with other projects so I can't make any promises, though.

Thanks, I was not aware of the context menu item for translating a selection, that takes care of a lot of the situations where this issue arises and is definitely something I'll be using a lot going forward.

I'm glad to hear that you'll find that feature useful!


As far as working on the issue myself, it hadn't occurred to me but I am a developer in my day job so I guess it's a fair suggestion. :)
If you could point to the general vicinity of the codebase to look at, I can take a peek. I'm pretty busy with other projects so I can't make any promises, though.

Sure thing! I'll have to do a similar sort of writeup regardless as the mentor for this Good First Bug.


Steps to Implement

The main logic changes will likely lie in the onChangeFromLanguage handler.

We would need an extra bit of logic before the call to onChangeLanguages that checks if this.elements.toMenuList.value has no currently selected language.

From there, we would need to call TranslationsParent.getTopPreferredSupportedToLang, passing in the newly selected from-language as the language tag to exclude.

We could then set the toMenuList value directly to the language tag that we get in return.

Note: some of these links to example calls are in unrelated areas of the code, but just show how the function is called.

That should be the entirety of the implementation. A test will need to be added, however.

We have a bunch of tests to look at as examples. This new test case probably makes most sense to add to browser_translations_full_page_panel_switch_languages.js .

I can give more details about that if needed for whomever decides to implement this.

Assignee

Comment 4

2 months ago

Hello! I would love to work on this as this is tagged as a good first bug (I'm new). Or is Justin working on it already ?

Flags: needinfo?(dopefishjustin)

Hi builder.sahaj,

You are certainly welcome to work on this.

I am only making an assumption based on Justin's prior message, but they said, "I'm pretty busy with other projects so I can't make any promises, though," which signals to me that they wouldn't be too upset if someone else took up this work.

Please feel free to give it a try.

Assignee

Comment 6

2 months ago

(In reply to Erik Nordin [:nordzilla] from comment #5)

Hi builder.sahaj,

You are certainly welcome to work on this.

I am only making an assumption based on Justin's prior message, but they said, "I'm pretty busy with other projects so I can't make any promises, though," which signals to me that they wouldn't be too upset if someone else took up this work.

Please feel free to give it a try.

Ok, I am on it. Thank you.

Flags: needinfo?(dopefishjustin)
Reporter

Comment 7

1 month ago

Sure, go ahead.

Assignee

Comment 8

1 month ago

Thank you for the implementation steps. I have implemented it and am to write a test for this. While all the e2e tests ( browser/components/translations/tests/browser/ ) pass I would really appreciate if you give more details on this .

(In reply to Erik Nordin [:nordzilla] from comment #3)

We have a bunch of tests to look at as examples. This new test case probably makes most sense to add to browser_translations_full_page_panel_switch_languages.js .

I can give more details about that if needed for whomever decides to implement this.

Flags: needinfo?(enordin)

Hi Sahaj, thanks for your work on this!

If you have a working implementation, just without tests for now, please submit it for review and we can continue the discussion in review.

https://firefox-source-docs.mozilla.org/contributing/how_to_submit_a_patch.html

Flags: needinfo?(enordin)
Assignee

Comment 10

1 month ago

This is for when the user is on a page and changes the from language in translation.
We don't have a way to suggest the to language, even if the user almost everytime
selects the same language. This improves the user experience.

Assignee: nobody → builder.sahaj
Status: NEW → ASSIGNED
Attachment #9572195 - Attachment description: Bug 2031015 - Suggest the default target language for translation after changing the detected source language. r=nordzilla → Bug 2031015 - Improve full-page Translations experince when changing source language r=nordzilla
Pushed by enordin@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/242c60757e03 https://hg.mozilla.org/integration/autoland/rev/af4c655f9915 Improve full-page Translations experince when changing source language r=nordzilla,translations-reviewers
Status: ASSIGNED → RESOLVED
Closed: 1 month ago
Resolution: --- → FIXED
Target Milestone: --- → 152 Branch

Hey Sahaj,

Congratulations on landing this bug.

Please feel free to join the conversation on Matrix in the #Firefox Translations.

Instructions on how to join Mozilla's Matrix server can be found here:


Note: I am requesting a "Need Info" to ensure that you are notified about this. Feel free to clear it. There is no action needed.

Flags: needinfo?(builder.sahaj)
Assignee

Updated

1 month ago
Flags: needinfo?(builder.sahaj)
QA Whiteboard: [qa-triage-done-c153/b152]
You need to log in before you can comment on or make changes to this bug.