www

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

commit 55b2dc39bf6d0127579b355d2f92c919ced0f00b
parent 59edca783e2b2cff520b2af9e986315ab8b21ea3
Author: Dan Stillman <dstillman@zotero.org>
Date:   Sun,  9 Jul 2017 06:56:56 -0400

Fix Firefox 55 breakage (and remove unnecessary locale lookups)

We were manually looking up the current locale in various places and
passing it to nsIStringBundleService::createBundle(), but that hasn't
even been a supported argument for years. (I assume it was a long time
ago?)

Diffstat:
Mchrome/content/zotero/icon.js | 12+-----------
Mchrome/content/zotero/xpcom/zotero.js | 53++++++++++++++++++++++++++++-------------------------
Mchrome/content/zotero/zoteroPane.js | 10+---------
Mchrome/skin/default/zotero/timeline/timelineControls.js | 11+----------
Mcomponents/zotero-service.js | 10+---------
5 files changed, 32 insertions(+), 64 deletions(-)

diff --git a/chrome/content/zotero/icon.js b/chrome/content/zotero/icon.js @@ -257,20 +257,10 @@ function getTooltipText(button) { // Use defaults if necessary if (!text) { - // Get the stringbundle manually - Components.utils.import("resource://gre/modules/Services.jsm"); - let appLocale; - if (Services.locale.getAppLocale) { - appLocale = Services.locale.getAppLocale(); - } - // Fx <=53 - else { - appLocale = Services.locale.getApplicationLocale(); - } let src = 'chrome://zotero/locale/zotero.properties'; let stringBundleService = Components.classes["@mozilla.org/intl/stringbundle;1"] .getService(Components.interfaces.nsIStringBundleService); - let stringBundle = stringBundleService.createBundle(src, appLocale); + let stringBundle = stringBundleService.createBundle(src); text = stringBundle.GetStringFromName('startupError'); } } diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js @@ -240,24 +240,13 @@ Services.scriptloader.loadSubScript("resource://zotero/polyfill.js"); this.locale = this.locale + '-' + this.locale.toUpperCase(); } - // Load in the localization stringbundle for use by getString(name) - if (Services.locale.getAppLocale) { - var appLocale = Services.locale.getAppLocale(); - } - // Fx <=53 - else { - var appLocale = Services.locale.getApplicationLocale(); - } - - _localizedStringBundle = Services.strings.createBundle( - "chrome://zotero/locale/zotero.properties", appLocale); + _localizedStringBundle = Services.strings.createBundle("chrome://zotero/locale/zotero.properties"); // Fix logged error in PluralForm.jsm when numForms() is called before get(), as it is in // getString() when a number is based PluralForm.get(1, '1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16') // Also load the brand as appName - var brandBundle = Services.strings.createBundle( - "chrome://branding/locale/brand.properties", appLocale); + var brandBundle = Services.strings.createBundle("chrome://branding/locale/brand.properties"); this.appName = brandBundle.GetStringFromName("brandShortName"); // Set the locale direction to Zotero.dir @@ -1313,19 +1302,33 @@ Services.scriptloader.loadSubScript("resource://zotero/polyfill.js"); return this.collation; } - if (Services.locale.getAppLocale) { - var locale = Services.locale.getAppLocale(); - } - // Fx <=53 - else { - var locale = Services.locale.getApplicationLocale(); - locale = locale.getCategory('NSILOCALE_COLLATE'); - } - try { - // Extract a valid language tag - locale = locale.match(/^[a-z]{2}(\-[A-Z]{2})?/)[0]; - var collator = new Intl.Collator(locale, { + // DEBUG: Is this necessary, or will Intl.Collator just default to the same locales we're + // passing manually? + + let locales; + // Fx55+ + if (Services.locale.getAppLocalesAsBCP47) { + locales = Services.locale.getAppLocalesAsBCP47(); + } + else { + let locale; + // Fx54 + if (Services.locale.getAppLocale) { + locale = Services.locale.getAppLocale(); + } + // Fx <=53 + else { + locale = Services.locale.getApplicationLocale(); + locale = locale.getCategory('NSILOCALE_COLLATE'); + } + + // Extract a valid language tag + locale = locale.match(/^[a-z]{2}(\-[A-Z]{2})?/)[0]; + locales = [locale]; + } + + var collator = new Intl.Collator(locales, { ignorePunctuation: true, numeric: true, sensitivity: 'base' diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js @@ -4697,18 +4697,10 @@ var ZoteroPane = new function() var errFunc = Zotero.startupErrorHandler; } - // Get the stringbundle manually - if (Services.locale.getAppLocale) { - var appLocale = Services.locale.getAppLocale(); - } - // Fx <=53 - else { - var appLocale = Services.locale.getApplicationLocale(); - } var stringBundleService = Components.classes["@mozilla.org/intl/stringbundle;1"] .getService(Components.interfaces.nsIStringBundleService); var src = 'chrome://zotero/locale/zotero.properties'; - var stringBundle = stringBundleService.createBundle(src, appLocale); + var stringBundle = stringBundleService.createBundle(src); var title = stringBundle.GetStringFromName('general.error'); if (!errMsg) { diff --git a/chrome/skin/default/zotero/timeline/timelineControls.js b/chrome/skin/default/zotero/timeline/timelineControls.js @@ -6,19 +6,10 @@ var lastJumpToYearValue; * Set up the localization string bundle from timeline.properties */ function initLocaleBundle() { - Components.utils.import("resource://gre/modules/Services.jsm"); - if (Services.locale.getAppLocale) { - var appLocale = Services.locale.getAppLocale(); - } - // Fx <=53 - else { - var appLocale = Services.locale.getApplicationLocale(); - } - var src = 'chrome://zotero/locale/timeline.properties'; var stringBundleService = Components.classes["@mozilla.org/intl/stringbundle;1"] .getService(Components.interfaces.nsIStringBundleService); - return stringBundleService.createBundle(src, appLocale); + return stringBundleService.createBundle(src); } /* diff --git a/components/zotero-service.js b/components/zotero-service.js @@ -378,18 +378,10 @@ function ZoteroService() { let quitStr = "Quit"; let checkForUpdateStr = "Check for Update"; try { - let appLocale; - if (Services.locale.getAppLocale) { - appLocale = Services.locale.getAppLocale(); - } - // Fx <=53 - else { - appLocale = Services.locale.getApplicationLocale(); - } let src = 'chrome://zotero/locale/zotero.properties'; let stringBundleService = Components.classes["@mozilla.org/intl/stringbundle;1"] .getService(Components.interfaces.nsIStringBundleService); - let stringBundle = stringBundleService.createBundle(src, appLocale); + let stringBundle = stringBundleService.createBundle(src); errorStr = stringBundle.GetStringFromName('general.error'); checkForUpdateStr = stringBundle.GetStringFromName('general.checkForUpdate'); quitStr = stringBundle.GetStringFromName('general.quit');