[Pkg-mozext-commits] [perspectives-extension] 29/44: Perspectives - Create wrapper functions for retrieving stringbundle strings
David Prévot
taffit at moszumanska.debian.org
Sun Jun 26 04:59:20 UTC 2016
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository perspectives-extension.
commit d54844ce027b4ab2714c901cb9fd9bffaa5e96a0
Author: Dave Schaefer <dave.schaefer at gmail.com>
Date: Tue Jun 14 20:54:17 2016 -0700
Perspectives - Create wrapper functions for retrieving stringbundle strings
Callers shouldn't have to know about internal state
or any details.
---
plugin/chrome/content/common.js | 16 ++++------------
plugin/chrome/content/notaries.js | 23 +++++++++++++++++++++++
2 files changed, 27 insertions(+), 12 deletions(-)
diff --git a/plugin/chrome/content/common.js b/plugin/chrome/content/common.js
index 6ea1dbd..390f293 100644
--- a/plugin/chrome/content/common.js
+++ b/plugin/chrome/content/common.js
@@ -235,12 +235,8 @@ var Pers_util = {
}
root_prefs.setCharPref("extensions.perspectives.default_notary_list",notary_list_data);
} catch(e) {
- if(Perspectives.strbundle === null) {
- Perspectives.strbundle = document.getElementById("notary_strings");
- }
-
- Pers_util.pers_alert(Perspectives.strbundle.
- getFormattedString("updateDefaultListWebError", [e]));
+ Pers_debug.d_print("error", Perspectives.getFormattedString(
+ "updateDefaultListWebError", [e]));
}
},
@@ -250,12 +246,8 @@ var Pers_util = {
var notary_list_data = this.readFileFromURI("chrome://perspectives/content/http_notary_list.txt");
root_prefs.setCharPref("extensions.perspectives.default_notary_list",notary_list_data);
} catch(e) {
- if(Perspectives.strbundle === null) {
- Perspectives.strbundle = document.getElementById("notary_strings");
- }
-
- Pers_util.pers_alert(Perspectives.strbundle.
- getFormattedString("updateDefaultListFileError", [e]));
+ Pers_debug.d_print("error", Perspectives.getFormattedString(
+ "updateDefaultListFileError", [e]));
}
},
diff --git a/plugin/chrome/content/notaries.js b/plugin/chrome/content/notaries.js
index 5087310..c20bfbc 100644
--- a/plugin/chrome/content/notaries.js
+++ b/plugin/chrome/content/notaries.js
@@ -40,6 +40,7 @@ var Perspectives = {
// Always call init_data() before working with these variables!
root_prefs : null,
overrideService : null,
+ notaryBundle: null,
/*
Note: calls to Components.classes.getService() require special permissions.
@@ -144,6 +145,28 @@ var Perspectives = {
return Perspectives.overrideService
},
+ // return a localized string from a string bundle
+ getString: function(name) {
+ if (Perspectives.notaryBundle === null) {
+ Perspectives.notaryBundle =
+ Components.classes["@mozilla.org/intl/stringbundle;1"]
+ .getService(Components.interfaces.nsIStringBundleService)
+ .createBundle("chrome://perspectives/locale/notaries.properties");
+ }
+ return Perspectives.notaryBundle.GetStringFromName(name);
+ },
+
+ // return a formatted localized string from a string bundle
+ getFormattedString: function(name, args) {
+ if (Perspectives.notaryBundle === null) {
+ Perspectives.notaryBundle =
+ Components.classes["@mozilla.org/intl/stringbundle;1"]
+ .getService(Components.interfaces.nsIStringBundleService)
+ .createBundle("chrome://perspectives/locale/notaries.properties");
+ }
+ return Perspectives.notaryBundle.formatStringFromName(name, args, args.length);
+ },
+
is_nonrouted_ip: function(ip_str) {
for(var i = 0; i < Perspectives.nonrouted_ips.length; i++) {
if(ip_str.match(Perspectives.nonrouted_ips[i])) {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/perspectives-extension.git
More information about the Pkg-mozext-commits
mailing list