www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 810e0a32395db415c9554740989819754e1d392f
parent c7fd46e6b4e0f1f2f8add47dc16b9435661c39eb
Author: Dan Stillman <dstillman@zotero.org>
Date:   Thu, 16 Nov 2017 01:18:42 -0500

Add Zotero.getStringFromBundle()

The same as Zotero.getString(), but takes an nsIStringBundle as the
first parameter. Extensions could use this to get the same getString()
features with their own properties files.

Diffstat:
Mchrome/content/zotero/xpcom/zotero.js | 14+++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js @@ -1407,15 +1407,20 @@ Services.scriptloader.loadSubScript("resource://zotero/polyfill.js"); * separated by semicolons */ this.getString = function (name, params, num) { + return this.getStringFromBundle(_localizedStringBundle, ...arguments); + } + + + this.getStringFromBundle = function (bundle, name, params, num) { try { if (params != undefined) { if (typeof params != 'object'){ params = [params]; } - var l10n = _localizedStringBundle.formatStringFromName(name, params, params.length); + var l10n = bundle.formatStringFromName(name, params, params.length); } else { - var l10n = _localizedStringBundle.GetStringFromName(name); + var l10n = bundle.GetStringFromName(name); } if (num !== undefined) { let availableForms = l10n.split(/;/); @@ -1435,10 +1440,9 @@ Services.scriptloader.loadSubScript("resource://zotero/polyfill.js"); Zotero.debug(params, 1); } else if (e.name != 'NS_ERROR_FAILURE') { - Components.utils.reportError(e); - Zotero.debug(e, 1); + Zotero.logError(e); } - throw ('Localized string not available for ' + name); + throw new Error('Localized string not available for ' + name); } return l10n; }