From cbdc75df9a5c02b20c475c251b014e3996376c62 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Tue, 3 Jun 2014 14:08:33 -0400 Subject: [PATCH] Fix search condition handling when two conditions have same translation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This prevented one "Numéro" from working in the French locale. Also do a proper collation sort --- chrome/content/zotero/xpcom/search.js | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/chrome/content/zotero/xpcom/search.js b/chrome/content/zotero/xpcom/search.js index 1853d70f0..e1456a27c 100644 --- a/chrome/content/zotero/xpcom/search.js +++ b/chrome/content/zotero/xpcom/search.js @@ -2274,8 +2274,7 @@ Zotero.SearchConditions = new function(){ _conditions[conditions[i]['name']] = conditions[i]; } - var sortKeys = []; - var sortValues = []; + _standardConditions = []; var baseMappedFields = Zotero.ItemFields.getBaseMappedFields(); @@ -2299,23 +2298,18 @@ Zotero.SearchConditions = new function(){ continue; } - var localized = self.getLocalizedName(i); - - sortKeys.push(localized); - sortValues[localized] = { + _standardConditions.push({ name: i, - localized: localized, + localized: self.getLocalizedName(i), operators: _conditions[i]['operators'], flags: _conditions[i]['flags'] - }; + }); } - // Alphabetize by localized name - // TODO: locale collation sort - sortKeys = sortKeys.sort(); - for each(var i in sortKeys){ - _standardConditions.push(sortValues[i]); - } + var collation = Zotero.getLocaleCollation(); + _standardConditions.sort(function(a, b) { + return collation.compareString(1, a.localized, b.localized); + }); _initialized = true; }