Commit 604917b6 authored by Greg Tatum's avatar Greg Tatum
Browse files

Bug 1829687 - Add translations command to app menu; r=nordzilla,fluent-reviewers,flod

This adds the translations panel to the app menu, per UX's
recommendation. The menu is hidden by default until the translations
pref is enabled.

Differential Revision: https://phabricator.services.mozilla.com/D179088
parent d729409e
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -98,6 +98,10 @@
                     data-l10n-id="appmenuitem-find-in-page"
                     key="key_find"
                     command="cmd_find"/>
      <toolbarbutton id="appMenu-translate-button"
                     class="subviewbutton"
                     data-l10n-id="appmenuitem-translate"
                     command="cmd_translate"/>
      <toolbaritem id="appMenu-zoom-controls" class="subviewbutton toolbaritem-combined-buttons" closemenu="none">
        <label class="toolbarbutton-text" data-l10n-id="appmenuitem-zoom"/>
        <toolbarbutton id="appMenu-zoomReduce-button2"
+1 −0
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@
#ifdef XP_MACOSX
    <command id="cmd_findSelection" oncommand="gLazyFindCommand('onFindSelectionCommand')"/>
#endif
    <command id="cmd_translate" oncommand="TranslationsPanel.open(event);"/>
    <!-- work-around bug 392512 -->
    <command id="Browser:AddBookmarkAs"
             oncommand="PlacesCommandHook.bookmarkPage();"/>
+23 −0
Original line number Diff line number Diff line
@@ -591,6 +591,13 @@ XPCOMUtils.defineLazyPreferenceGetter(
  }
);

XPCOMUtils.defineLazyPreferenceGetter(
  this,
  "gTranslationsEnabled",
  "browser.translations.enable",
  false
);

customElements.setElementCreationCallback("screenshots-buttons", () => {
  Services.scriptloader.loadSubScript(
    "chrome://browser/content/screenshots/screenshots-buttons.js",
@@ -5012,6 +5019,11 @@ var XULBrowserWindow = {
      "repair-text-encoding"
    ));
  },
  get _menuItemForTranslations() {
    delete this._menuItemForTranslations;
    return (this._menuItemForTranslations =
      document.getElementById("cmd_translate"));
  },

  setDefaultStatus(status) {
    this.defaultStatus = status;
@@ -5421,6 +5433,17 @@ var XULBrowserWindow = {
        element.setAttribute("disabled", "true");
      }
    }

    if (TranslationsParent.isRestrictedPage(gBrowser.currentURI.spec)) {
      this._menuItemForTranslations.setAttribute("disabled", "true");
    } else {
      this._menuItemForTranslations.removeAttribute("disabled");
    }
    if (gTranslationsEnabled) {
      this._menuItemForTranslations.removeAttribute("hidden");
    } else {
      this._menuItemForTranslations.setAttribute("hidden", "true");
    }
  },

  /**
+2 −0
Original line number Diff line number Diff line
@@ -37,6 +37,8 @@ appmenuitem-print =
  .label = Print…
appmenuitem-find-in-page =
    .label = Find in page…
appmenuitem-translate =
    .label = Translate page…
appmenuitem-zoom =
    .value = Zoom
appmenuitem-more-tools =