[Pkg-mozext-commits] [tabmixplus] 10/44: Add new function TabmixSvc.getDialogStrings to get commonDialogs.properties strings. bug 1219794 removed editBookmark.cancel.label entity from browser.dtd

David Prévot taffit at moszumanska.debian.org
Fri Mar 18 20:57:14 UTC 2016


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository tabmixplus.

commit ce47030928a97c510e3dcc31c23df58c581c7425
Author: onemen <tabmix.onemen at gmail.com>
Date:   Fri Feb 26 19:34:23 2016 +0200

    Add new function TabmixSvc.getDialogStrings to get commonDialogs.properties strings. bug 1219794 removed
    editBookmark.cancel.label entity from browser.dtd
---
 chrome/content/minit/renameTab.xul     |  1 -
 chrome/content/session/session.js      |  3 +--
 chrome/content/session/sessionStore.js | 10 ++--------
 modules/RenameTab.jsm                  |  2 ++
 modules/Services.jsm                   | 13 +++++++++++++
 5 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/chrome/content/minit/renameTab.xul b/chrome/content/minit/renameTab.xul
index fffae6e..df2e8f1 100644
--- a/chrome/content/minit/renameTab.xul
+++ b/chrome/content/minit/renameTab.xul
@@ -62,7 +62,6 @@
               oncommand="Tabmix.renameTab.update();"/>
       <button id="tabmixRenametab_deleteButton"
               class="editBookmarkPanelBottomButton"
-              label="&editBookmark.cancel.label;"
               oncommand="Tabmix.renameTab.hidePopup();"/>
     </hbox>
   </panel>
diff --git a/chrome/content/session/session.js b/chrome/content/session/session.js
index 7401d26..b9339a5 100644
--- a/chrome/content/session/session.js
+++ b/chrome/content/session/session.js
@@ -524,9 +524,8 @@ TabmixSessionManager = {
     var chkBoxLabel = TabmixSvc.getSMString("sm.saveClosedTab.chkbox.label");
     var chkBoxState = this.saveClosedTabs ? Tabmix.CHECKBOX_CHECKED : Tabmix.HIDE_CHECKBOX;
 
-    var stringBundle = Services.strings.createBundle("chrome://global/locale/commonDialogs.properties");
     var buttons = TabmixSvc.setLabel("sm.askBeforSave.button0") + "\n" +
-        stringBundle.GetStringFromName("Cancel") + "\n" +
+        TabmixSvc.getDialogStrings("Cancel") + "\n" +
         TabmixSvc.setLabel("sm.askBeforSave.button1");
     return Tabmix.promptService([Tabmix.BUTTON_OK, Tabmix.HIDE_MENUANDTEXT, chkBoxState],
                                 [title, msg, "", chkBoxLabel, buttons]);
diff --git a/chrome/content/session/sessionStore.js b/chrome/content/session/sessionStore.js
index 2fcd288..77999db 100644
--- a/chrome/content/session/sessionStore.js
+++ b/chrome/content/session/sessionStore.js
@@ -175,10 +175,7 @@ var TMP_SessionStore = { // jshint ignore:line
       let title = "TabMix " + TabmixSvc.getSMString("sm.title");
       let msg = start ? TabmixSvc.getSMString("sm.disable.msg") + "\n\n" : "";
       msg += TabmixSvc.getSMString("sm.disable.msg" + msgNo);
-      let bunService = Cc["@mozilla.org/intl/stringbundle;1"].
-      getService(Ci.nsIStringBundleService);
-      let bundle = bunService.createBundle("chrome://global/locale/commonDialogs.properties");
-      let buttons = [bundle.GetStringFromName("Yes"), bundle.GetStringFromName("No")].join("\n");
+      let buttons = TabmixSvc.getDialogStrings("Yes", "No").join("\n");
       let self = this;
       let callBack = function(aResult) {
         if ((msgNo == 1 && aResult.button == 1) || ((msgNo == 2 && aResult.button === 0))) {
@@ -723,10 +720,7 @@ var TabmixConvertSession = { // jshint ignore:line
   },
 
   confirm: function cs_confirm(aMsg, aCallBack) {
-    let bunService = Cc["@mozilla.org/intl/stringbundle;1"].
-    getService(Ci.nsIStringBundleService);
-    let bundle = bunService.createBundle("chrome://global/locale/commonDialogs.properties");
-    let buttons = [bundle.GetStringFromName("Yes"), bundle.GetStringFromName("No")].join("\n");
+    let buttons = TabmixSvc.getDialogStrings("Yes", "No").join("\n");
     return Tabmix.promptService([Tabmix.BUTTON_OK, Tabmix.HIDE_MENUANDTEXT, Tabmix.HIDE_CHECKBOX],
                                 [this.getTitle, aMsg, "", "", buttons], window, aCallBack);
   },
diff --git a/modules/RenameTab.jsm b/modules/RenameTab.jsm
index eab1dde..41dd754 100644
--- a/modules/RenameTab.jsm
+++ b/modules/RenameTab.jsm
@@ -68,6 +68,8 @@ this.RenameTab = {
     this.panel._overlayLoaded = true;
     this.panel.hidden = false;
 
+    this._element("tabmixRenametab_deleteButton").label = TabmixSvc.getDialogStrings("Cancel");
+
     // reorder buttons for MacOS & Linux
     if (TabmixSvc.isLinux || TabmixSvc.isMac) {
       let buttons = this._element("tabmixRenametab_buttons");
diff --git a/modules/Services.jsm b/modules/Services.jsm
index 0ec9348..d481dfc 100644
--- a/modules/Services.jsm
+++ b/modules/Services.jsm
@@ -86,6 +86,19 @@ this.TabmixSvc = {
     return label;
   },
 
+  getDialogStrings: function(...keys) {
+    let stringBundle = Services.strings.createBundle("chrome://global/locale/commonDialogs.properties");
+
+    return keys.map(key => {
+      try {
+        return stringBundle.GetStringFromName(key);
+      } catch (ex) {
+        this.console.log("Failed to get string " + key + " in bundle: commonDialogs.properties");
+        return key;
+      }
+    });
+  },
+
   topWin: function() {
     return Services.wm.getMostRecentWindow("navigator:browser");
   },

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/tabmixplus.git



More information about the Pkg-mozext-commits mailing list