forked from Floorp-Projects/Floorp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1710546 - Firefox Translations integration r=mossop,mixedpuppy,mhoye
Bundle Firefox Translation as a builtin pref'd off addon in Nightly only Differential Revision: https://phabricator.services.mozilla.com/D114810
- Loading branch information
1 parent
65c295f
commit 3d8a198
Showing
33 changed files
with
50,309 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1975,6 +1975,35 @@ BrowserGlue.prototype = { | |
}); | ||
}, | ||
|
||
// Set up a listener to enable/disable the translation extension | ||
// based on its preference. | ||
_monitorTranslationsPref() { | ||
const PREF = "extensions.translations.disabled"; | ||
const ID = "[email protected]"; | ||
const _checkTranslationsPref = async () => { | ||
let addon = await AddonManager.getAddonByID(ID); | ||
let disabled = Services.prefs.getBoolPref(PREF, false); | ||
if (!addon && disabled) { | ||
// not installed, bail out early. | ||
return; | ||
} | ||
if (!disabled) { | ||
// first time install of addon and install on firefox update | ||
addon = | ||
(await AddonManager.maybeInstallBuiltinAddon( | ||
ID, | ||
"0.4.0", | ||
"resource://builtin-addons/translations/" | ||
)) || addon; | ||
await addon.enable(); | ||
} else if (addon) { | ||
await addon.disable(); | ||
} | ||
}; | ||
Services.prefs.addObserver(PREF, _checkTranslationsPref); | ||
_checkTranslationsPref(); | ||
}, | ||
|
||
_monitorHTTPSOnlyPref() { | ||
const PREF_ENABLED = "dom.security.https_only_mode"; | ||
const PREF_WAS_ENABLED = "dom.security.https_only_mode_ever_enabled"; | ||
|
@@ -2172,6 +2201,9 @@ BrowserGlue.prototype = { | |
this._monitorHTTPSOnlyPref(); | ||
this._monitorIonPref(); | ||
this._monitorIonStudies(); | ||
if (AppConstants.NIGHTLY_BUILD) { | ||
this._monitorTranslationsPref(); | ||
} | ||
|
||
FirefoxMonitor.init(); | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,8 @@ DIRS += [ | |
"report-site-issue", | ||
"pictureinpicture", | ||
] | ||
|
||
if CONFIG["NIGHTLY_BUILD"]: | ||
DIRS += [ | ||
"translations", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
This folder contains the source files for Firefox Translations, which utilizes | ||
the proceedings from Project Bergamot [1]. | ||
|
||
The feature is developed as a webextension [2] which utilizes a neural machine | ||
translation decoder [3] ported to WebAssembly in order to process the | ||
in page translation. The translation models [4] are downloaded on-demand by the | ||
extension, so there's no need to bundle them too. | ||
|
||
The folder `extension_src` contains the entire code of the extension's xpi and | ||
the wasm module (which lies inside the folder wasm), and is automatically | ||
generated by the `import_xpi.py` script, which is responsibile for cloning | ||
the extension repo [2], build it, and generate the `jar.mn` package containing | ||
all the pertinent files necessary for running it. | ||
|
||
For any questions, reach out to [email protected]. | ||
|
||
[1] https://browser.mt/ | ||
[2] https://github.com/mozilla-extensions/bergamot-browser-extension | ||
[3] https://github.com/mozilla/bergamot-translator/ | ||
[4] https://github.com/mozilla-applied-ml/bergamot-models |
46 changes: 46 additions & 0 deletions
46
browser/extensions/translations/extension/_locales/en_US/messages.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{ | ||
"extensionName": { | ||
"message": "Firefox Translations", | ||
"description": "Name of the extension" | ||
}, | ||
"extensionDescription": { | ||
"message": "Neural Machine Translation for the browser.", | ||
"description": "Description of the extension." | ||
}, | ||
"currentlyDownloadingLanguageModel": { | ||
"message": "Currently downloading language model", | ||
"description": "Informs the user that the translations feature is currently downloading the language model files." | ||
}, | ||
"detailedDownloadProgress": { | ||
"message": "$PERCENTAGE$% out of $MB$ mb downloaded", | ||
"description": "Informs the user how the language model file downloading is progressing.", | ||
"placeholders": { | ||
"percentage": { | ||
"content": "$1", | ||
"example": "50" | ||
}, | ||
"mb": { | ||
"content": "$2", | ||
"example": "22.2" | ||
} | ||
} | ||
}, | ||
"currentlyLoadingLanguageModel": { | ||
"message": "Currently loading language model", | ||
"description": "Informs the user that the translations feature is currently loading the language model files into memory." | ||
}, | ||
"loadedLanguageModel": { | ||
"message": "Language model loaded", | ||
"description": "Informs the user that the translations feature is has loaded the language model files into memory." | ||
}, | ||
"partsLeftToTranslate": { | ||
"message": "Parts left to translate: $NUM$", | ||
"description": "Informs the user that the translations feature has $NUM$ parts left to translate.", | ||
"placeholders": { | ||
"num": { | ||
"content": "$1", | ||
"example": "3" | ||
} | ||
} | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
browser/extensions/translations/extension/_locales/es_ES/messages.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{ | ||
"extensionName": { | ||
"message": "Traducciones de Firefox", | ||
"description": "Name of the extension" | ||
}, | ||
"extensionDescription": { | ||
"message": "Traducción de la Máquina Neural para el navegador.", | ||
"description": "Description of the extension." | ||
}, | ||
"currentlyDownloadingLanguageModel": { | ||
"message": "Actualmente descargando el modelo de idioma", | ||
"description": "Informs the user that the translations feature is currently downloading the language model files." | ||
}, | ||
"detailedDownloadProgress": { | ||
"message": "$PERCENTAGE$% de $MB$ mb descargado", | ||
"description": "Informs the user how the language model file downloading is progressing.", | ||
"placeholders": { | ||
"percentage": { | ||
"content": "$1", | ||
"example": "50" | ||
}, | ||
"mb": { | ||
"content": "$2", | ||
"example": "22.2" | ||
} | ||
} | ||
}, | ||
"currentlyLoadingLanguageModel": { | ||
"message": "Actualmente cargar el modelo de idioma", | ||
"description": "Informs the user that the translations feature is currently loading the language model files into memory." | ||
}, | ||
"loadedLanguageModel": { | ||
"message": "Modelo de lenguaje cargado", | ||
"description": "Informs the user that the translations feature is has loaded the language model files into memory." | ||
}, | ||
"partsLeftToTranslate": { | ||
"message": "Partes que quedan para traducir: $NUM$", | ||
"description": "Informs the user that the translations feature has $NUM$ parts left to translate.", | ||
"placeholders": { | ||
"num": { | ||
"content": "$1", | ||
"example": "3" | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.