Bug 1899354 Comment 0 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

### Description

Bug 1870368 patch [D211230](https://phabricator.services.mozilla.com/D211230) introduced a cache to the `SelectTranslationsPanel` which includes the document's determined language tag.

This cached information is occasionally used in our fallback algorithm for when we detect that the selected text is in a language that is not yet supported by translations. In this case, we check the document's language tag, to see if the page's language is supported, and attempt to fall back to that in case the selected text was misidentified. 

This cache was not being properly cleared between page loads, and it causes the panel to fall back to the document language of the previous page in this scenario, rather than the current page. 

---

### Steps to reproduce

* Go to a page in a supported language, such as `fi.wikipedia.org`. 
* Select a paragraph of text on the page.
* Open the `SelectTranslationsPanel` from the right-click context menu, and ensure that a valid translation completes in the document's language.
* Next, navigate to `ru.wikipedia.org` and select the "Welcome to Wikipedia" at the top of the page: "Добро пожаловать в Википедию". Note, it is important to test with this exact string because our current language detector misidentifies this string as Serbian, which we currently do not support.
* Open the `SelectTranslationsPanel` from the right-click context menu.

**Expected Behavior**
The `SelectTranslationsPanel` opens and translates from Russian, based on the **current** document's language tag.

**Actual Behavior**
The `SelectTranslationsPanel` opens and translates from the previous document's language (Finnish in this STR), based on the **previous** document's cached language tag. 

---

### Steps to implement

* Ensure that the cache is properly cleared between navigating to other pages.

---

### Tests to implement

* Create a test case the reproduces the above situation, and ensure that the fallbacking is for the correct language.
### Description

Bug 1870368 patch [D211230](https://phabricator.services.mozilla.com/D211230) introduced a cache to the `SelectTranslationsPanel` which includes the document's determined language tag.

This cached information is occasionally used in our fallback algorithm for when we detect that the selected text is in a language that is not yet supported by translations. In this case, we check the document's language tag, to see if the page's language is supported, and attempt to fall back to that in case the selected text was misidentified. 

This cache was not being properly cleared between page loads, and it causes the panel to fall back to the document language of the previous page in this scenario, rather than the current page. 

---

### Steps to reproduce

* Go to a page in a supported language, such as fi.wikipedia.org. 
* Select a paragraph of text on the page.
* Open the `SelectTranslationsPanel` from the right-click context menu, and ensure that a valid translation completes in the document's language.
* Next, navigate to ru.wikipedia.org and select the "Welcome to Wikipedia" at the top of the page: "Добро пожаловать в Википедию". Note, it is important to test with this exact string because our current language detector misidentifies this string as Serbian, which we currently do not support.
* Open the `SelectTranslationsPanel` from the right-click context menu.

**Expected Behavior**
The `SelectTranslationsPanel` opens and translates from Russian, based on the **current** document's language tag.

**Actual Behavior**
The `SelectTranslationsPanel` opens and translates from the previous document's language (Finnish in this STR), based on the **previous** document's cached language tag. 

---

### Steps to implement

* Ensure that the cache is properly cleared between navigating to other pages.

---

### Tests to implement

* Create a test case the reproduces the above situation, and ensure that the fallbacking is for the correct language.
### Description

Bug 1870368 patch [D211230](https://phabricator.services.mozilla.com/D211230) introduced a cache to the `SelectTranslationsPanel` which includes the document's determined language tag.

This cached information is occasionally used in our fallback algorithm for when we detect that the selected text is in a language that is not yet supported by translations. In this case, we check the document's language tag, to see if the page's language is supported, and attempt to fall back to that in case the selected text was misidentified. 

This cache was not being properly cleared between page loads, and it causes the panel to fall back to the document language of the previous page in this scenario, rather than the current page. 

---

### Steps to reproduce

* Go to a page in a supported language, such as https://fi.wikipedia.org. 
* Select a paragraph of text on the page.
* Open the `SelectTranslationsPanel` from the right-click context menu, and ensure that a valid translation completes in the document's language.
* Next, navigate to https://ru.wikipedia.org and select the "Welcome to Wikipedia" at the top of the page: "Добро пожаловать в Википедию". Note, it is important to test with this exact string because our current language detector misidentifies this string as Serbian, which we currently do not support.
* Open the `SelectTranslationsPanel` from the right-click context menu.

**Expected Behavior**
The `SelectTranslationsPanel` opens and translates from Russian, based on the **current** document's language tag.

**Actual Behavior**
The `SelectTranslationsPanel` opens and translates from the previous document's language (Finnish in this STR), based on the **previous** document's cached language tag. 

---

### Steps to implement

* Ensure that the cache is properly cleared between navigating to other pages.

---

### Tests to implement

* Create a test case the reproduces the above situation, and ensure that the fallbacking is for the correct language.

Back to Bug 1899354 Comment 0