Bug 1548478 - Fix fluent warnings about missing translations for Bookmark Panel messages r=zbraniecki
authorAndrei Oprea <andrei.br92@gmail.com>
Mon, 20 May 2019 15:02:22 +0000
changeset 474535 17f72de310de6d19e1e20b956cb757ed8e51d4c1
parent 474534 eb23da0a276b0927f0839bd6f53f15d5beef87ec
child 474536 2bb901b8e9f5f6ecc198393136a8bfbf25b16ba2
push id36042
push userdvarga@mozilla.com
push dateTue, 21 May 2019 04:19:40 +0000
treeherdermozilla-central@ca560ff55451 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerszbraniecki
bugs1548478
milestone69.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1548478 - Fix fluent warnings about missing translations for Bookmark Panel messages r=zbraniecki Differential Revision: https://phabricator.services.mozilla.com/D30060
browser/components/newtab/lib/BookmarkPanelHub.jsm
--- a/browser/components/newtab/lib/BookmarkPanelHub.jsm
+++ b/browser/components/newtab/lib/BookmarkPanelHub.jsm
@@ -33,20 +33,17 @@ class _BookmarkPanelHub {
    * @param {function} handleMessageRequest
    * @param {function} addImpression
    * @param {function} dispatch - Used for sending user telemetry information
    */
   init(handleMessageRequest, addImpression, dispatch) {
     this._handleMessageRequest = handleMessageRequest;
     this._addImpression = addImpression;
     this._dispatch = dispatch;
-    this._l10n = new DOMLocalization([
-      "browser/branding/sync-brand.ftl",
-      "browser/newtab/asrouter.ftl",
-    ]);
+    this._l10n = new DOMLocalization();
     this._initialized = true;
   }
 
   uninit() {
     this._l10n = null;
     this._initialized = false;
     this._handleMessageRequest = null;
     this._addImpression = null;
@@ -87,16 +84,19 @@ class _BookmarkPanelHub {
       ...response,
       collapsed: false,
       target,
       win,
       url: target.url,
     };
 
     if (response && response.content) {
+      // Only insert localization files if we need to show a message
+      win.MozXULElement.insertFTLIfNeeded("browser/newtab/asrouter.ftl");
+      win.MozXULElement.insertFTLIfNeeded("browser/branding/sync-brand.ftl");
       this.showMessage(response.content, target, win);
       this.sendImpression();
       this.sendUserEventTelemetry("IMPRESSION", win);
     } else {
       this.hideMessage(target);
     }
 
     target.infoButton.disabled = !response;
@@ -144,17 +144,16 @@ class _BookmarkPanelHub {
       this._l10n.setAttributes(content, message.text);
       const cta = createElement("button");
       cta.setAttribute("id", "editBookmarkPanelRecommendationCta");
       this._l10n.setAttributes(cta, message.cta);
       recommendation.appendChild(close);
       recommendation.appendChild(title);
       recommendation.appendChild(content);
       recommendation.appendChild(cta);
-      this._l10n.translateElements([...recommendation.children]);
       target.container.appendChild(recommendation);
     }
 
     this.toggleRecommendation(true);
   }
 
   toggleRecommendation(visible) {
     const {target} = this._response;