diff --git a/chrome/content/zotero/icon.js b/chrome/content/zotero/icon.js index a64de7e77..88caf7348 100644 --- 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 index 51c9b4600..3c4dff3fc 100644 --- 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 index 17779a8b5..7ca1d8456 100644 --- 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 index 536447cf1..3ebfdcbc1 100644 --- 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 index 917edca11..41d1506cb 100644 --- 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');