From d5a8a3420da821533ed9bce9e48f3321c20822a9 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Fri, 26 May 2017 01:37:54 -0400 Subject: [PATCH] Additional locale service updates for Firefox 54 compatibility Follow-up to 0ac37ab65a4 --- chrome/content/zotero/icon.js | 12 +++++++++--- chrome/content/zotero/xpcom/zotero.js | 10 +++++++--- chrome/content/zotero/zoteroPane.js | 12 ++++++++---- .../default/zotero/timeline/timelineControls.js | 15 ++++++++++----- components/zotero-service.js | 11 ++++++++--- 5 files changed, 42 insertions(+), 18 deletions(-) diff --git a/chrome/content/zotero/icon.js b/chrome/content/zotero/icon.js index 09d311d1a0..a64de7e77f 100644 --- a/chrome/content/zotero/icon.js +++ b/chrome/content/zotero/icon.js @@ -258,10 +258,16 @@ 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 localeService = Components.classes['@mozilla.org/intl/nslocaleservice;1'] - .getService(Components.interfaces.nsILocaleService); - let appLocale = localeService.getApplicationLocale(); let stringBundleService = Components.classes["@mozilla.org/intl/stringbundle;1"] .getService(Components.interfaces.nsIStringBundleService); let stringBundle = stringBundleService.createBundle(src, appLocale); diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js index 02354b3a9b..d0260f2e86 100644 --- a/chrome/content/zotero/xpcom/zotero.js +++ b/chrome/content/zotero/xpcom/zotero.js @@ -1329,9 +1329,13 @@ Services.scriptloader.loadSubScript("resource://zotero/polyfill.js"); return this.collation; } - var localeService = Components.classes["@mozilla.org/intl/nslocaleservice;1"] - .getService(Components.interfaces.nsILocaleService); - var appLocale = localeService.getApplicationLocale(); + if (Services.locale.getAppLocale) { + var appLocale = Services.locale.getAppLocale(); + } + // Fx <=53 + else { + var appLocale = Services.locale.getApplicationLocale(); + } try { var locale = appLocale.getCategory('NSILOCALE_COLLATE'); diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js index 07fb05b01d..1129d161d7 100644 --- a/chrome/content/zotero/zoteroPane.js +++ b/chrome/content/zotero/zoteroPane.js @@ -4710,12 +4710,16 @@ var ZoteroPane = new function() } // Get the stringbundle manually - var src = 'chrome://zotero/locale/zotero.properties'; - var localeService = Components.classes['@mozilla.org/intl/nslocaleservice;1']. - getService(Components.interfaces.nsILocaleService); - var appLocale = localeService.getApplicationLocale(); + 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 title = stringBundle.GetStringFromName('general.error'); diff --git a/chrome/skin/default/zotero/timeline/timelineControls.js b/chrome/skin/default/zotero/timeline/timelineControls.js index 9fde290085..536447cf12 100644 --- a/chrome/skin/default/zotero/timeline/timelineControls.js +++ b/chrome/skin/default/zotero/timeline/timelineControls.js @@ -6,13 +6,18 @@ var lastJumpToYearValue; * Set up the localization string bundle from timeline.properties */ function initLocaleBundle() { - var src = 'chrome://zotero/locale/timeline.properties'; - var localeService = Components.classes['@mozilla.org/intl/nslocaleservice;1'] - .getService(Components.interfaces.nsILocaleService); - var appLocale = localeService.getApplicationLocale(); + 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); + .getService(Components.interfaces.nsIStringBundleService); return stringBundleService.createBundle(src, appLocale); } diff --git a/components/zotero-service.js b/components/zotero-service.js index 5f3077eba5..c42f8498b5 100644 --- a/components/zotero-service.js +++ b/components/zotero-service.js @@ -390,10 +390,15 @@ 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 localeService = Components.classes['@mozilla.org/intl/nslocaleservice;1'] - .getService(Components.interfaces.nsILocaleService); - let appLocale = localeService.getApplicationLocale(); let stringBundleService = Components.classes["@mozilla.org/intl/stringbundle;1"] .getService(Components.interfaces.nsIStringBundleService); let stringBundle = stringBundleService.createBundle(src, appLocale);