Skip to content
This repository has been archived by the owner on Sep 4, 2023. It is now read-only.

Do not display the translationbar to non-supported languagues #47

Merged
merged 3 commits into from
Jan 26, 2022

Conversation

andrenatal
Copy link
Contributor

fixes #34

@abhi-agg
Copy link
Collaborator

@andrenatal One question. Is there a test for this?

@@ -93,4 +93,8 @@ class TranslationNotificationManager {
const message = { command: "displayStatistics", tabId: this.tabId };
this.bgScriptListenerCallback(message);
}

isPageLanguageSupported(){
return this.languageSet.has(this.detectedLanguage);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should check that language pair page-lang->user-lang or page-lang->en and en->user-lang are supported. Models of opposite directions are completely decoupled from each other and we can support only one-way translation.

Copy link
Contributor Author

@andrenatal andrenatal Jan 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After giving this a second thought there's some assumptions we are making about this issue for free that I'm not sure if they are right:

  • We are putting to much trust that the cld module will return the right language, and we already know how naive that module is and its flaws (like confusing es and pt very often)
  • We are assuming that the portion of the page's content to be analyzed to always be representative of the majority of the page's language.

So I think this is more complicated than just preventing the infobar of displaying when the supposed page's language do not match what exists in the model registry. Before that we'll need to review the cld and the page's language analysis first and also decide if we want to actually prevent the infobar of displaying or not (maybe we want to always display it and only don't auto select the language we think it represents the page?). Many new sites localize some parts of the page, and mix languages. How do we detect that? In that case a deep learning based cld would work better than ngrams like cld2 which is what we have. I heard cld4(?) is nn based.

In a normal world that would be a UI + product decision, but since we know we don't have that, we'll need to figure out something reasonable ourselves.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should definitely work on improving cld accuracy but I don't think always displaying the infobar will be useful. Our language coverage is pretty limited atm and displaying just to show that we don't support the page language will be annoying for users. I would suggest assuming cld works correctly and relying on its output here, abstract from it and work on this issue separately.

@@ -61,7 +61,7 @@ class Mediator {
if (!this.languageDetection.navigatorLanguage.includes(this.languageDetection.pageLanguage.language)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code inside "if" statement shouldn't be called if language pair is not supported. It triggers calls to infobar and creates unnecessary Translation object. Also we'll need to record "unsupported" metrics from mediator. It means we need to read model registry from mediator and move the check here from TranslationNotificationManager.

Copy link
Contributor Author

@andrenatal andrenatal Jan 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

| Also we'll need to record "unsupported" metrics from mediator.

Could you please elaborate on what does this mean? That we are supposed to send a ping every time a page is not supported by the extension (i.e. all the time the user browses to a new page?)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See this todo. We should always record "unsupported" metric. How the ping sending is triggered is decoupled from recording. In the current implementation, it happens on page closing. If it won't work for us, we can move this metric to a different ping and send it on timer in the future.

Copy link
Contributor Author

@andrenatal andrenatal Jan 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so this means sending a ping to every page a user browses to any page, no? At least one ping will always be sent if the page's lang is either supported or unsupported?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only when language mismatch happens. Yes, exactly one ping will be sent if the user language is different from the page language in the current implementation.

@andrenatal
Copy link
Contributor Author

andrenatal commented Jan 24, 2022

@andrenatal One question. Is there a test for this?

@abhi-agg please see #49

Wanna take a stab at that?

@andrenatal andrenatal merged commit a374d9b into mozilla:main Jan 26, 2022
@andrenatal andrenatal deleted the issue34 branch February 19, 2022 04:50
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Infobar is displayed for unsupported languages
3 participants