www

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

commit 979e62714cfe1f431f77fec121f7c014916ccbe1
parent 9f379c99e0f46e291bc486e2d598879b27aa9f32
Author: Dan Stillman <dstillman@zotero.org>
Date:   Wed, 25 Jun 2014 12:14:28 -0400

Fix startup errors in some non-English locales in Fx30 on OS X

nsICollation broke for some locales. (Testing requires changing the
language setting in Language & Region and then restarting the computer.
The change seems to not fully go into effect until then, even though the
UI changes.) This is fixed in Nightly, but we can work around it by
using the new Intl.Collator.

Diffstat:
Mchrome/content/zotero/xpcom/zotero.js | 31+++++++++++++++++++++++++------
1 file changed, 25 insertions(+), 6 deletions(-)

diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js @@ -67,7 +67,6 @@ Components.utils.import("resource://gre/modules/Services.jsm"); this.safeDebug = safeDebug; this.getString = getString; this.localeJoin = localeJoin; - this.getLocaleCollation = getLocaleCollation; this.setFontSize = setFontSize; this.flattenArguments = flattenArguments; this.getAncestorByTagName = getAncestorByTagName; @@ -1467,12 +1466,32 @@ Components.utils.import("resource://gre/modules/Services.jsm"); } - function getLocaleCollation() { + this.getLocaleCollation = function () { + if (this.collation) { + return this.collation; + } + var localeService = Components.classes["@mozilla.org/intl/nslocaleservice;1"] - .getService(Components.interfaces.nsILocaleService); - var collationFactory = Components.classes["@mozilla.org/intl/collation-factory;1"] - .getService(Components.interfaces.nsICollationFactory); - return collationFactory.CreateCollation(localeService.getApplicationLocale()); + .getService(Components.interfaces.nsILocaleService); + var appLocale = localeService.getApplicationLocale(); + + // Use nsICollation before Fx29 + if (Zotero.platformMajorVersion < 29) { + var localeService = Components.classes["@mozilla.org/intl/nslocaleservice;1"] + .getService(Components.interfaces.nsILocaleService); + var collationFactory = Components.classes["@mozilla.org/intl/collation-factory;1"] + .getService(Components.interfaces.nsICollationFactory); + return this.collation = collationFactory.CreateCollation(appLocale); + } + + var locale = appLocale.getCategory('NSILOCALE_COLLATE'); + var collator = new Intl.Collator(locale); + // Until old code is updated, pretend we're returning an nsICollation + return this.collation = { + compareString: function (_, a, b) { + return collator.compare(a, b); + } + }; }