Bug 1164410 - fix l10n use in pocket, r=jaws a=dolske
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Tue, 12 May 2015 18:21:08 +0100
changeset 260493 48eaac80d6b5
parent 260492 06499c7a81a9
child 260494 99ea3c3c13f6
push id799
push userjdolske@mozilla.com
push date2015-05-14 03:46 +0000
treeherdermozilla-release@11c4678a21bb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws, dolske
bugs1164410
milestone38.0.1
Bug 1164410 - fix l10n use in pocket, r=jaws a=dolske
browser/base/content/baseMenuOverlay.xul
browser/base/content/browser-places.js
browser/base/content/browser-pocket-en-US.properties
browser/base/content/browser-pocket.properties
browser/base/content/nsContextMenu.js
browser/base/jar.mn
browser/components/customizableui/CustomizableWidgets.jsm
--- a/browser/base/content/baseMenuOverlay.xul
+++ b/browser/base/content/baseMenuOverlay.xul
@@ -107,11 +107,10 @@
              key="&hideOtherAppsCmdMac.commandkey;"
              modifiers="accel,alt"/>
 #endif
     </keyset>
 
     <stringbundleset id="stringbundleset">
         <stringbundle id="bundle_browser" src="chrome://browser/locale/browser.properties"/>
         <stringbundle id="bundle_browser_region" src="chrome://browser-region/locale/region.properties"/>
-        <stringbundle id="bundle_pocket" src="chrome://browser/content/browser-pocket.properties"/>
     </stringbundleset>
 </overlay>
--- a/browser/base/content/browser-places.js
+++ b/browser/base/content/browser-places.js
@@ -1431,25 +1431,27 @@ let BookmarkingUI = {
   },
 
   updatePocketItemVisibility: function BUI_updatePocketItemVisibility(prefix) {
     let hidden = !CustomizableUI.getPlacementOfWidget("pocket-button");
     if (!hidden) {
       let locale = Cc["@mozilla.org/chrome/chrome-registry;1"].
                    getService(Ci.nsIXULChromeRegistry).
                    getSelectedLocale("browser");
-      let url = "chrome://browser/content/browser-pocket-" + locale + ".properties";
-      let bundle = Services.strings.createBundle(url);
-      let item = document.getElementById(prefix + "pocket");
-      try {
-        item.setAttribute("label", bundle.GetStringFromName("pocketMenuitem.label"));
-      } catch (err) {
-        // GetStringFromName throws when the bundle doesn't exist.  In that
-        // case, the item will retain the browser-pocket.dtd en-US string that
-        // it has in the markup.
+      if (locale != "en-US") {
+        let url = "chrome://browser/content/browser-pocket-" + locale + ".properties";
+        let bundle = Services.strings.createBundle(url);
+        let item = document.getElementById(prefix + "pocket");
+        try {
+          item.setAttribute("label", bundle.GetStringFromName("pocketMenuitem.label"));
+        } catch (err) {
+          // GetStringFromName throws when the bundle doesn't exist.  In that
+          // case, the item will retain the browser-pocket.dtd en-US string that
+          // it has in the markup.
+        }
       }
     }
     document.getElementById(prefix + "pocket").hidden = hidden;
     document.getElementById(prefix + "pocketSeparator").hidden = hidden;
   },
 
   _showBookmarkedNotification: function BUI_showBookmarkedNotification() {
     function getCenteringTransformForRects(rectToPosition, referenceRect) {
rename from browser/base/content/browser-pocket.properties
rename to browser/base/content/browser-pocket-en-US.properties
--- a/browser/base/content/nsContextMenu.js
+++ b/browser/base/content/nsContextMenu.js
@@ -236,26 +236,28 @@ nsContextMenu.prototype = {
       canPocket =
         CustomizableUI.getPlacementOfWidget("pocket-button") &&
         (uri.schemeIs("http") || uri.schemeIs("https") ||
          (uri.schemeIs("about") && ReaderMode.getOriginalUrl(uri.spec)));
       if (canPocket) {
         let locale = Cc["@mozilla.org/chrome/chrome-registry;1"].
                      getService(Ci.nsIXULChromeRegistry).
                      getSelectedLocale("browser");
-        let url = "chrome://browser/content/browser-pocket-" + locale + ".properties";
-        let bundle = Services.strings.createBundle(url);
-        let item = document.getElementById("context-pocket");
-        try {
-          item.setAttribute("label", bundle.GetStringFromName("saveToPocketCmd.label"));
-          item.setAttribute("accesskey", bundle.GetStringFromName("saveToPocketCmd.accesskey"));
-        } catch (err) {
-          // GetStringFromName throws when the bundle doesn't exist.  In that
-          // case, the item will retain the browser-pocket.dtd en-US string that
-          // it has in the markup.
+        if (locale != "en-US") {
+          let url = "chrome://browser/content/browser-pocket-" + locale + ".properties";
+          let bundle = Services.strings.createBundle(url);
+          let item = document.getElementById("context-pocket");
+          try {
+            item.setAttribute("label", bundle.GetStringFromName("saveToPocketCmd.label"));
+            item.setAttribute("accesskey", bundle.GetStringFromName("saveToPocketCmd.accesskey"));
+          } catch (err) {
+            // GetStringFromName throws when the bundle doesn't exist.  In that
+            // case, the item will retain the browser-pocket.dtd en-US string that
+            // it has in the markup.
+          }
         }
       }
     }
     this.showItem("context-pocket", canPocket && window.pktApi && window.pktApi.isUserLoggedIn());
   },
 
   initViewItems: function CM_initViewItems() {
     // View source is always OK, unless in directory listing.
--- a/browser/base/jar.mn
+++ b/browser/base/jar.mn
@@ -70,17 +70,17 @@ browser.jar:
         content/browser/aboutSocialError.xhtml        (content/aboutSocialError.xhtml)
         content/browser/aboutProviderDirectory.xhtml  (content/aboutProviderDirectory.xhtml)
         content/browser/aboutTabCrashed.css           (content/aboutTabCrashed.css)
         content/browser/aboutTabCrashed.js            (content/aboutTabCrashed.js)
         content/browser/aboutTabCrashed.xhtml         (content/aboutTabCrashed.xhtml)
 *       content/browser/browser.css                   (content/browser.css)
 *       content/browser/browser.js                    (content/browser.js)
 *       content/browser/browser.xul                   (content/browser.xul)
-        content/browser/browser-pocket.properties     (content/browser-pocket.properties)
+        content/browser/browser-pocket-en-US.properties (content/browser-pocket-en-US.properties)
         content/browser/browser-pocket.dtd            (content/browser-pocket.dtd)
         content/browser/browser-pocket-de.properties  (content/browser-pocket-de.properties)
         content/browser/browser-pocket-es-ES.properties (content/browser-pocket-es-ES.properties)
         content/browser/browser-pocket-ja.properties  (content/browser-pocket-ja.properties)
         content/browser/browser-pocket-ru.properties  (content/browser-pocket-ru.properties)
 *       content/browser/browser-tabPreviews.xml       (content/browser-tabPreviews.xml)
 *       content/browser/chatWindow.xul                (content/chatWindow.xul)
         content/browser/content.js                    (content/content.js)
--- a/browser/components/customizableui/CustomizableWidgets.jsm
+++ b/browser/components/customizableui/CustomizableWidgets.jsm
@@ -1083,17 +1083,17 @@ if (Services.prefs.getBoolPref("browser.
     let label;
     let tooltiptext;
     try {
       label = strings.GetStringFromName("pocket-button.label");
       tooltiptext = strings.GetStringFromName("pocket-button.tooltiptext");
     } catch (err) {
       // GetStringFromName throws when the bundle doesn't exist.  In that case,
       // fall back to the en-US browser-pocket.properties.
-      url = "chrome://browser/content/browser-pocket.properties";
+      url = "chrome://browser/content/browser-pocket-en-US.properties";
       strings = Services.strings.createBundle(url);
       label = strings.GetStringFromName("pocket-button.label");
       tooltiptext = strings.GetStringFromName("pocket-button.tooltiptext");
     }
 
     let pocketButton = {
       id: "pocket-button",
       defaultArea: CustomizableUI.AREA_NAVBAR,