Bug 1861516 - Remove Translations useFastText pref r=gregtatum

Removes the browser.translations.languageIdentification.useFastText
pref, making CLD2 the only option for language identification
for Translations.

Differential Revision: https://phabricator.services.mozilla.com/D192656
This commit is contained in:
Erik Nordin 2023-11-08 23:38:36 +00:00
parent 35000161a2
commit fd6099b149
6 changed files with 1 additions and 50 deletions

View File

@ -3627,13 +3627,6 @@ pref("browser.translations.simulateUnsupportedEngine", false);
pref("browser.translations.chaos.errors", false);
pref("browser.translations.chaos.timeoutMS", 0);
// A pref to manage the use of fastText for language detection in Translations.
// The feature was initially built using fastText, but we are now putting it
// behind a pref while we investigate some performance improvements.
// In the meantime, we will use CLD2, which is already available in tree.
// See https://bugzilla.mozilla.org/show_bug.cgi?id=1836974
pref("browser.translations.languageIdentification.useFastText", false);
// When a user cancels this number of authentication dialogs coming from
// a single web page in a row, all following authentication dialogs will
// be blocked (automatically canceled) for that page. The counter resets

View File

@ -2,8 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
const lazy = {};
ChromeUtils.defineLazyGetter(lazy, "console", () => {
@ -18,12 +16,6 @@ ChromeUtils.defineESModuleGetters(lazy, {
"resource://gre/modules/translation/LanguageDetector.sys.mjs",
});
XPCOMUtils.defineLazyPreferenceGetter(
lazy,
"useFastTextPref",
"browser.translations.languageIdentification.useFastText"
);
/**
* @typedef {import("./TranslationsChild.sys.mjs").LanguageIdEngine} LanguageIdEngine
* @typedef {import("./TranslationsChild.sys.mjs").TranslationsEngine} TranslationsEngine
@ -276,20 +268,6 @@ export class AboutTranslationsChild extends JSWindowActorChild {
* @returns {Promise<{ langTag: string, confidence: number }>}
*/
AT_identifyLanguage(message) {
if (lazy.useFastTextPref) {
if (!this.languageIdEngine) {
const { Promise, Error } = this.contentWindow;
return Promise.reject(
new Error("The language identification was not created.")
);
}
return this.#convertToContentPromise(
this.languageIdEngine
.identifyLanguage(message)
.then(data => Cu.cloneInto(data, this.contentWindow))
);
}
return this.#convertToContentPromise(
lazy.LanguageDetector.detectLanguage(message).then(data =>
Cu.cloneInto(

View File

@ -78,16 +78,6 @@ export class TranslationsChild extends JSWindowActorChild {
}
try {
// Try to use the fastText engine if directed to do so.
if (data.useFastText) {
const engine = await this.getOrCreateLanguageIdEngine();
if (!engine) {
return null;
}
return engine.identifyLanguageFromDocument(this.document);
}
// Use the CLD2 language detector otherwise.
return lazy.LanguageDetector.detectLanguageFromDocument(
this.document
);

View File

@ -120,12 +120,6 @@ XPCOMUtils.defineLazyPreferenceGetter(
"browser.translations.simulateUnsupportedEngine"
);
XPCOMUtils.defineLazyPreferenceGetter(
lazy,
"useFastTextPref",
"browser.translations.languageIdentification.useFastText"
);
// At this time the signatures of the files are not being checked when they are being
// loaded from disk. This signature check involves hitting the network, and translations
// are explicitly an offline-capable feature. See Bug 1827265 for re-enabling this
@ -2161,9 +2155,7 @@ export class TranslationsParent extends JSWindowActorParent {
) {
return null;
}
return this.sendQuery("Translations:IdentifyLanguage", {
useFastText: lazy.useFastTextPref,
}).catch(error => {
return this.sendQuery("Translations:IdentifyLanguage").catch(error => {
if (this.#isDestroyed) {
// The actor was destroyed while this message was still being resolved.
return null;

View File

@ -179,7 +179,6 @@ add_task(async function test_about_translations_language_identification() {
{ fromLang: "en", toLang: "fr" },
{ fromLang: "fr", toLang: "en" },
],
prefs: [["browser.translations.languageIdentification.useFastText", true]],
runInPage: async ({ selectors }) => {
const { document, window } = content;
Cu.waiveXrays(window).DEBOUNCE_DELAY = 5; // Make the timer run faster for tests.

View File

@ -101,7 +101,6 @@ add_task(async function test_language_identification_for_page_translation() {
detectedLangTag: "es",
detectedLanguageConfidence: 0.95,
resolveLanguageIdDownloads: true,
prefs: [["browser.translations.languageIdentification.useFastText", true]],
languagePairs: [
{ fromLang: "es", toLang: "en" },
{ fromLang: "en", toLang: "es" },