mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 02:14:43 +00:00
Bug 1805476 - Stub out an about:translations page with no real functionality; r=nordzilla
This page is hidden behind a pref, but not behind an ifdef. I chose to do this in order to simplify the potential release of this feature. I don't foresee issues with bloating the binary during the development, so this doesn't feel like a risk to me. Differential Revision: https://phabricator.services.mozilla.com/D164613
This commit is contained in:
parent
26997d3819
commit
a254222081
@ -1820,9 +1820,16 @@ pref("media.videocontrols.picture-in-picture.video-toggle.enabled", true);
|
||||
pref("media.videocontrols.picture-in-picture.video-toggle.visibility-threshold", "1.0");
|
||||
pref("media.videocontrols.picture-in-picture.keyboard-controls.enabled", true);
|
||||
|
||||
// Preferences for the older translation service backed by external services. This is
|
||||
// planned to be replaced with an integration of the Firefox Translations service.
|
||||
// The prefs for the new service are located under "browser.translations" in
|
||||
// modules/libpref/init/all.js
|
||||
//
|
||||
// See Bug 971044.
|
||||
pref("browser.translation.detectLanguage", false);
|
||||
pref("browser.translation.neverForLanguages", "");
|
||||
// Show the translation UI bits, like the info bar, notification icon and preferences.
|
||||
// Show the older translation UI that uses external services. This includes UI such as
|
||||
// the info bar, notification icon and preferences.
|
||||
pref("browser.translation.ui.show", false);
|
||||
// Allows to define the translation engine. Google is default, Bing or Yandex are other options.
|
||||
pref("browser.translation.engine", "Google");
|
||||
|
@ -777,6 +777,8 @@ let JSWINDOWACTORS = {
|
||||
allFrames: true,
|
||||
},
|
||||
|
||||
// The older translations feature backed by external services.
|
||||
// This is being replaced by a newer ML-backed translation service. See Bug 971044.
|
||||
Translation: {
|
||||
parent: {
|
||||
moduleURI: "resource:///modules/translation/TranslationParent.jsm",
|
||||
|
9
browser/locales-preview/translations.ftl
Normal file
9
browser/locales-preview/translations.ftl
Normal file
@ -0,0 +1,9 @@
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# 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/.
|
||||
|
||||
### TODO (Bug 1814257) - This file should be moved from /browser/locales-preview folder
|
||||
### to an appropriate place in /toolkit when it is no longer preview.
|
||||
|
||||
about-translations-title = Translations
|
||||
about-translations-header = { -translations-brand-name }
|
@ -15,6 +15,7 @@
|
||||
preview/identityCredentialNotification.ftl (../components/credentialmanager/identityCredentialNotification.ftl)
|
||||
preview/cookieBannerPreferences.ftl (../components/preferences/cookieBannerPreferences.ftl)
|
||||
locales-preview/migrationWizard.ftl (../locales-preview/migrationWizard.ftl)
|
||||
locales-preview/translations.ftl (../locales-preview/translations.ftl)
|
||||
browser (%browser/**/*.ftl)
|
||||
|
||||
@AB_CD@.jar:
|
||||
|
@ -169,6 +169,11 @@ static const RedirEntry kRedirMap[] = {
|
||||
#endif
|
||||
{"telemetry", "chrome://global/content/aboutTelemetry.xhtml",
|
||||
nsIAboutModule::ALLOW_SCRIPT | nsIAboutModule::IS_SECURE_CHROME_UI},
|
||||
{"translations", "chrome://global/content/translations/translations.html",
|
||||
nsIAboutModule::ALLOW_SCRIPT |
|
||||
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
|
||||
nsIAboutModule::URI_MUST_LOAD_IN_CHILD |
|
||||
nsIAboutModule::HIDE_FROM_ABOUTABOUT},
|
||||
{"url-classifier", "chrome://global/content/aboutUrlClassifier.xhtml",
|
||||
nsIAboutModule::ALLOW_SCRIPT},
|
||||
{"webrtc", "chrome://global/content/aboutwebrtc/aboutWebrtc.html",
|
||||
|
@ -30,6 +30,7 @@ about_pages = [
|
||||
'srcdoc',
|
||||
'support',
|
||||
'telemetry',
|
||||
'translations',
|
||||
'url-classifier',
|
||||
'webrtc',
|
||||
]
|
||||
|
@ -3802,6 +3802,16 @@ pref("browser.storageManager.pressureNotification.usageThresholdGB", 5);
|
||||
|
||||
pref("browser.sanitizer.loglevel", "Warn");
|
||||
|
||||
// Enable Firefox translations based on Bergamot[1]. This project is in-development and
|
||||
// an effort to integrate the Firefox Translations[2] project direcly into Gecko.
|
||||
// See Bug 971044.
|
||||
//
|
||||
// [1]: https://browser.mt/
|
||||
// [2]: https://github.com/mozilla/firefox-translations
|
||||
pref("browser.translations.enable", false);
|
||||
// Set to "All" to see all logs, which are useful for debugging.
|
||||
pref("browser.translations.logLevel", "Error");
|
||||
|
||||
// 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
|
||||
|
@ -74,6 +74,7 @@ DIRS += [
|
||||
"statusfilter",
|
||||
"telemetry",
|
||||
"translation",
|
||||
"translations",
|
||||
"thumbnails",
|
||||
"timermanager",
|
||||
"tooltiptext",
|
||||
|
3
toolkit/components/translations/README.md
Normal file
3
toolkit/components/translations/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
# Firefox Translations (Work in Progress)
|
||||
|
||||
This folder contains the work in progress integration of Firefox Translations directly into Firefox. See Bug 971044.
|
@ -0,0 +1,26 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* 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 = {};
|
||||
|
||||
XPCOMUtils.defineLazyGetter(lazy, "console", () => {
|
||||
return console.createInstance({
|
||||
maxLogLevelPref: "browser.translations.logLevel",
|
||||
prefix: "Translations",
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* The AboutTranslationsChild is responsible for coordinating what privileged APIs
|
||||
* are exposed to the un-privileged scope of the about:translations page.
|
||||
*/
|
||||
export class AboutTranslationsChild extends JSWindowActorChild {
|
||||
handleEvent(event) {
|
||||
if (event.type === "DOMDocElementInserted") {
|
||||
lazy.console.log("TODO");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* 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/. */
|
||||
|
||||
/**
|
||||
* This parent is blank because the Translations actor handles most of the features
|
||||
* needed in AboutTranslations.
|
||||
*/
|
||||
export class AboutTranslationsParent extends JSWindowActorParent {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* 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/. */
|
||||
|
||||
const lazy = {};
|
||||
|
||||
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
|
||||
|
||||
XPCOMUtils.defineLazyGetter(lazy, "console", () => {
|
||||
return console.createInstance({
|
||||
maxLogLevelPref: "browser.translations.logLevel",
|
||||
prefix: "Translations",
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* TODO - The translations actor will eventually be used to handle in-page translations
|
||||
* See Bug 971044
|
||||
*/
|
||||
export class TranslationsChild extends JSWindowActorChild {
|
||||
/**
|
||||
* @param {{ type: string }} event
|
||||
*/
|
||||
handleEvent(event) {
|
||||
// TODO
|
||||
lazy.console.log("TranslationsChild observed a pageshow event.");
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* 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/. */
|
||||
|
||||
/**
|
||||
* TODO - The translations actor will eventually be used to handle in-page translations
|
||||
* See Bug 971044
|
||||
*/
|
||||
export class TranslationsParent extends JSWindowActorParent {}
|
10
toolkit/components/translations/actors/moz.build
Normal file
10
toolkit/components/translations/actors/moz.build
Normal file
@ -0,0 +1,10 @@
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# 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/.
|
||||
|
||||
FINAL_TARGET_FILES.actors += [
|
||||
"AboutTranslationsChild.sys.mjs",
|
||||
"AboutTranslationsParent.sys.mjs",
|
||||
"TranslationsChild.sys.mjs",
|
||||
"TranslationsParent.sys.mjs",
|
||||
]
|
12
toolkit/components/translations/content/translations.css
Normal file
12
toolkit/components/translations/content/translations.css
Normal file
@ -0,0 +1,12 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* 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/. */
|
||||
|
||||
body {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
inset: 0;
|
||||
position: absolute;
|
||||
visibility: hidden;
|
||||
}
|
26
toolkit/components/translations/content/translations.html
Normal file
26
toolkit/components/translations/content/translations.html
Normal file
@ -0,0 +1,26 @@
|
||||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- 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/. -->
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="Content-Security-Policy" content="default-src chrome:; object-src 'none'">
|
||||
<meta name="color-scheme" content="light dark">
|
||||
|
||||
<title data-l10n-id="about-translations-title"></title>
|
||||
|
||||
<link rel="stylesheet" href="chrome://global/skin/global.css" type="text/css"/>
|
||||
<link rel="stylesheet" href="chrome://global/skin/in-content/common.css" type="text/css"/>
|
||||
<link rel="stylesheet" href="chrome://global/content/translations/translations.css">
|
||||
|
||||
<link rel="localization" href="browser/branding/brandings.ftl"/>
|
||||
<link rel="localization" href="locales-preview/translations.ftl"/>
|
||||
|
||||
<script type="module" src="chrome://global/content/translations/translations.mjs"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1 data-l10n-id="about-translations-header"></h1>
|
||||
</body>
|
||||
</html>
|
20
toolkit/components/translations/content/translations.mjs
Normal file
20
toolkit/components/translations/content/translations.mjs
Normal file
@ -0,0 +1,20 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* 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/. */
|
||||
|
||||
/**
|
||||
* While the feature is in development, hide the feature behind a pref. See
|
||||
* modules/libpref/init/all.js and Bug 971044 for the status of enabling this project.
|
||||
*/
|
||||
function updateEnabledState() {
|
||||
if (Services.prefs.getBoolPref("browser.translations.enable")) {
|
||||
document.body.style.visibility = "visible";
|
||||
} else {
|
||||
document.body.style.visibility = "hidden";
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener("DOMContentLoaded", () => {
|
||||
updateEnabledState();
|
||||
Services.prefs.addObserver("browser.translations.enable", updateEnabledState);
|
||||
});
|
8
toolkit/components/translations/jar.mn
Normal file
8
toolkit/components/translations/jar.mn
Normal file
@ -0,0 +1,8 @@
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# 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/.
|
||||
|
||||
toolkit.jar:
|
||||
content/global/translations/translations.html (content/translations.html)
|
||||
content/global/translations/translations.css (content/translations.css)
|
||||
content/global/translations/translations.mjs (content/translations.mjs)
|
10
toolkit/components/translations/moz.build
Normal file
10
toolkit/components/translations/moz.build
Normal file
@ -0,0 +1,10 @@
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# 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/.
|
||||
|
||||
JAR_MANIFESTS += ["jar.mn"]
|
||||
|
||||
with Files("**"):
|
||||
BUG_COMPONENT = ("Firefox", "Translation")
|
||||
|
||||
DIRS += ["actors"]
|
@ -89,6 +89,22 @@ let JSWINDOWACTORS = {
|
||||
allFrames: true,
|
||||
},
|
||||
|
||||
AboutTranslations: {
|
||||
parent: {
|
||||
esModuleURI: "resource://gre/actors/AboutTranslationsParent.sys.mjs",
|
||||
},
|
||||
child: {
|
||||
esModuleURI: "resource://gre/actors/AboutTranslationsChild.sys.mjs",
|
||||
events: {
|
||||
// Run the actor before any content of the page appears.
|
||||
DOMDocElementInserted: {},
|
||||
},
|
||||
},
|
||||
matches: ["about:translations"],
|
||||
|
||||
enablePreference: "browser.translations.enable",
|
||||
},
|
||||
|
||||
AudioPlayback: {
|
||||
parent: {
|
||||
moduleURI: "resource://gre/actors/AudioPlaybackParent.jsm",
|
||||
@ -476,6 +492,21 @@ let JSWINDOWACTORS = {
|
||||
},
|
||||
},
|
||||
|
||||
// The newer translations feature backed by local machine learning models.
|
||||
// See Bug 971044.
|
||||
Translations: {
|
||||
parent: {
|
||||
esModuleURI: "resource://gre/actors/TranslationsParent.sys.mjs",
|
||||
},
|
||||
child: {
|
||||
esModuleURI: "resource://gre/actors/TranslationsChild.sys.mjs",
|
||||
events: {
|
||||
pageshow: {},
|
||||
},
|
||||
},
|
||||
enablePreference: "browser.translations.enable",
|
||||
},
|
||||
|
||||
UAWidgets: {
|
||||
child: {
|
||||
moduleURI: "resource://gre/actors/UAWidgetsChild.jsm",
|
||||
|
Loading…
Reference in New Issue
Block a user