From d369e5f571b437aed1f599c6aee8a980319446b8 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Mon, 16 Apr 2007 05:22:05 +0000 Subject: [PATCH] Fix diacritic sorting (and possible other locale-specific collation issues) for bibliographies --- chrome/content/zotero/xpcom/cite.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/chrome/content/zotero/xpcom/cite.js b/chrome/content/zotero/xpcom/cite.js index 446714bac..f2e94b266 100644 --- a/chrome/content/zotero/xpcom/cite.js +++ b/chrome/content/zotero/xpcom/cite.js @@ -989,6 +989,12 @@ Zotero.CSL.prototype._serializeElement = function(name, element) { * handles sorting of items */ Zotero.CSL.prototype._compareItem = function(a, b, opt) { + 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); + var collation = collationFactory.CreateCollation(localeService.getApplicationLocale()); + for(var i in this._bib.sortOrder) { var sortElement = this._bib.sortOrder[i]; @@ -1020,10 +1026,9 @@ Zotero.CSL.prototype._compareItem = function(a, b, opt) { var bValue = formattedStringB.get().toLowerCase(); //Zotero.debug(aValue+" vs "+bValue); - if(bValue > aValue) { - return -1; - } else if(bValue < aValue) { - return 1; + var cmp = collation.compareString(0, aValue, bValue); + if(cmp != 0) { + return cmp; } } }