Files
lbmk/config/firefox/default/patches/0015-fullpage-translations-customization.patch.patch
T
Leah Rowe 2b34aeea5d WIP: convert to lwmk
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-08 06:44:40 +01:00

180 lines
7.1 KiB
Diff

From 61b38ed69d7f2660775f702da1df6a1b9dd84a2a Mon Sep 17 00:00:00 2001
From: LibreWolf Developers <noreply@librewolf.net>
Date: Sun, 6 Sep 2026 10:10:05 +0100
Subject: [PATCH 15/52] fullpage-translations-customization.patch
---
browser/base/content/main-popupset.inc.xhtml | 2 +
browser/base/content/main-popupset.js | 3 ++
.../preferences/config/languages.mjs | 1 +
browser/components/preferences/main.inc.xhtml | 11 ++++-
browser/components/preferences/main.js | 43 ++++++++++---------
.../content/fullPageTranslationsPanel.js | 9 ++++
6 files changed, 47 insertions(+), 22 deletions(-)
diff --git a/browser/base/content/main-popupset.inc.xhtml b/browser/base/content/main-popupset.inc.xhtml
index 47603929dbad..459b7b426c4b 100644
--- a/browser/base/content/main-popupset.inc.xhtml
+++ b/browser/base/content/main-popupset.inc.xhtml
@@ -1005,6 +1005,8 @@
type="checkbox"
autocheck="false"
id="translations-panel-settings-never-translate-site"/>
+ <menuitem data-l10n-id="translations-panel-disable-translations"
+ id="translations-panel-disable-translations"/>
<menuseparator/>
<menuitem class="manage-languages-menuitem"
data-l10n-id="translations-panel-settings-manage-languages"
diff --git a/browser/base/content/main-popupset.js b/browser/base/content/main-popupset.js
index 1286fba14b0c..47cfc8b16858 100644
--- a/browser/base/content/main-popupset.js
+++ b/browser/base/content/main-popupset.js
@@ -438,6 +438,9 @@ document.addEventListener(
case "translations-panel-settings-never-translate-site":
FullPageTranslationsPanel.onNeverTranslateSite();
break;
+ case "translations-panel-disable-translations":
+ FullPageTranslationsPanel.openDisableTranslations();
+ break;
case "translations-panel-manage-languages":
FullPageTranslationsPanel.openManageLanguages();
break;
diff --git a/browser/components/preferences/config/languages.mjs b/browser/components/preferences/config/languages.mjs
index 7dd8ff65d59e..7123cb0f4639 100644
--- a/browser/components/preferences/config/languages.mjs
+++ b/browser/components/preferences/config/languages.mjs
@@ -20,6 +20,7 @@ Preferences.addAll([
{ id: "privacy.spoof_english", type: "int" },
{ id: "layout.spellcheckDefault", type: "int" },
{ id: "browser.translations.automaticallyPopup", type: "bool" },
+ { id: "browser.translations.enable", type: "bool" },
]);
/**
diff --git a/browser/components/preferences/main.inc.xhtml b/browser/components/preferences/main.inc.xhtml
index f6badc31b612..9ea6086f8b88 100644
--- a/browser/components/preferences/main.inc.xhtml
+++ b/browser/components/preferences/main.inc.xhtml
@@ -106,8 +106,16 @@
<!-- This Translations UI is the pre-settings-redesign UI and should be removed
when getting ready for the settings redesign to fully ship. -->
- <vbox id="translationsGroup" data-srd-groupid="translations" hidden="true" data-subcategory="translations">
+ <vbox id="translationsGroup" data-srd-groupid="translations" data-subcategory="translations">
<label><html:h2 data-l10n-id="translations-manage-header"/></label>
+ <checkbox id="translations-manage-enable"
+ data-l10n-id="translations-manage-enable"
+ preference="browser.translations.enable"
+ data-subcategory="translations-enable" />
+ <vbox id="innerTranslationsGroup" hidden="true">
+ <checkbox id="translations-manage-autopopup"
+ data-l10n-id="translations-manage-autopopup"
+ preference="browser.translations.automaticallyPopup" />
<hbox id="translations-manage-description" align="center">
<description flex="1" data-l10n-id="translations-manage-intro-2"/>
<button id="translations-manage-settings-button"
@@ -128,6 +136,7 @@
</html:div>
<description id="translations-manage-error" hidden="true"></description>
</vbox>
+ </vbox>
</vbox>
</groupbox>
diff --git a/browser/components/preferences/main.js b/browser/components/preferences/main.js
index 5a56d348146c..d75d3c81cfa5 100644
--- a/browser/components/preferences/main.js
+++ b/browser/components/preferences/main.js
@@ -713,6 +713,10 @@ var gMainPane = {
window.addEventListener("unload", this);
// Notify observers that the UI is now ready
+ Preferences.addSyncFromPrefListener(
+ document.getElementById("translations-manage-enable"),
+ () => this.readEnableTranslations()
+ );
Services.obs.notifyObservers(window, "main-pane-loaded");
this.setInitialized();
},
@@ -813,39 +817,36 @@ var gMainPane = {
button.disabled = !preference.value;
return undefined;
},
+
+ readEnableTranslations(skipInit = false) {
+ const translationsEnabled = Preferences.get("browser.translations.enable").value;
+ document.getElementById("innerTranslationsGroup").hidden = !translationsEnabled;
+ if (!this._translationsInitialized && !skipInit)
+ this.initTranslations();
+ },
+
+ _translationsInitialized: false,
+
/**
* Initialize the translations view.
*/
async initTranslations() {
- let legacyTranslationsVisible = Preferences.getSetting(
- "legacyTranslationsVisible"
- );
+ this.readEnableTranslations(true);
+
+ if (!Services.prefs.getBoolPref("browser.translations.enable")) {
+ return;
+ }
+
+ this._translationsInitialized = true;
+
/**
* Which phase a language download is in.
*
* @typedef {"downloaded" | "loading" | "uninstalled"} DownloadPhase
*/
- let translationsGroup = document.getElementById("translationsGroup");
- let setTranslationsGroupVisbility = () => {
- // Immediately show the group so that the async load of the component does
- // not cause the layout to jump. The group will be empty initially.
- translationsGroup.hidden = !legacyTranslationsVisible.visible;
- translationsGroup.classList.toggle(
- "setting-hidden",
- translationsGroup.hidden
- );
- };
- setTranslationsGroupVisbility();
- legacyTranslationsVisible.on("change", setTranslationsGroupVisbility);
- window.addEventListener(
- "unload",
- () =>
- legacyTranslationsVisible.off("change", setTranslationsGroupVisbility),
- { once: true }
- );
class TranslationsState {
/**
diff --git a/browser/components/translations/content/fullPageTranslationsPanel.js b/browser/components/translations/content/fullPageTranslationsPanel.js
index 91666d6e513c..f65017583ef1 100644
--- a/browser/components/translations/content/fullPageTranslationsPanel.js
+++ b/browser/components/translations/content/fullPageTranslationsPanel.js
@@ -1342,6 +1342,15 @@ var FullPageTranslationsPanel = new (class {
);
}
+ openDisableTranslations() {
+ const window =
+ gBrowser.selectedBrowser.browsingContext.top.embedderElement.ownerGlobal;
+ window.openTrustedLinkIn(
+ "about:preferences#general-translations-enable",
+ "tab"
+ );
+ }
+
/**
* Redirect the user to about:preferences
*/
--
2.47.3