www

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

commit 532ebc52398ac3ba88143ba58c5e25923ab129a0
parent 4a677240d36365fc29cd675ed744f6b5e4cb0835
Author: Dan Stillman <dstillman@zotero.org>
Date:   Fri, 27 Jun 2014 09:35:07 -0400

Fix for startup error w/weird locale language tags ("de-CH@currency=EUR")

https://forums.zotero.org/discussion/37901

And just return a noop sorter on failure instead of breaking

Diffstat:
Mchrome/content/zotero/xpcom/zotero.js | 19+++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js @@ -1484,8 +1484,23 @@ Components.utils.import("resource://gre/modules/Services.jsm"); return this.collation = collationFactory.CreateCollation(appLocale); } - var locale = appLocale.getCategory('NSILOCALE_COLLATE'); - var collator = new Intl.Collator(locale, { ignorePunctuation: true }); + try { + var locale = appLocale.getCategory('NSILOCALE_COLLATE'); + // Extract a valid language tag + locale = locale.match(/^[a-z]{2}(\-[A-Z]{2})?/)[0]; + var collator = new Intl.Collator(locale, { ignorePunctuation: true }); + } + catch (e) { + Zotero.debug(e, 1); + + // If there's an error, just skip sorting + collator = { + compare: function (a, b) { + return 0; + } + }; + } + // Until old code is updated, pretend we're returning an nsICollation return this.collation = { compareString: function (_, a, b) {