improve locale sensitive sorting of folder names

NEW
Unassigned

Status

--
enhancement
5 years ago
4 months ago

People

(Reporter: aceman, Unassigned)

Tracking

({intl})

Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

5 years ago
+++ This bug was initially created as a clone of Bug #981405 +++

Currently the folder sorting function mailnews/base/util/folderUtils.jsm::folderNameCompare() we use to sort folders in some folder pane modes (when we can't use compareSortKeys()) unconditionally uses .toLocaleLowerCase on both the strings to force a case insensitive comparison.

It seems this could be improved to use the new localeCompare functionality at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare, like this:
aString1.localeCompare(aString2, undefined, {usage:"sort", sensitivity: "accent"})

But for that TB needs to switch to the new internationalization API, something like in bug 853301.
(Reporter)

Updated

5 years ago
Severity: normal → enhancement
Keywords: regression
Summary: "Recent Folders" sorting has switched from case insensitive to case sensitive → improve locale sensitive sorting of folder names
Note that rather than repeatedly using localeCompare, it would be better to create an Intl.Collator instance and use it repeatedly, to save on work needed to set up collation resources.

Updated

4 months ago
Keywords: intl
(Reporter)

Comment 2

4 months ago
Waldo, something like at https://dxr.mozilla.org/mozilla-central/rev/0418c9abdeb18b216301e91022aa289a45d5b426/browser/components/preferences/languages.js#108 so that we keep the Collator object in a global variable for the folder tree?
If we set the language (first argument) to "undefined", will it pick up the UI language?
Flags: needinfo?(jwalden+bmo)
That looks about right.  Passing |undefined| is probably right, but there's an outside chance something like |navigator.language| is better; I remember some fussiness about exactly how that relates to default language in some contexts.  Probably |undefined| is right, tho, if that example does it that way.
Flags: needinfo?(jwalden+bmo)
You need to log in before you can comment on or make changes to this bug.