From f4b531e6571ad8507598fd276a8703e3fb4bb09b Mon Sep 17 00:00:00 2001 From: PChemGuy <39730837+pchemguy@users.noreply.github.com> Date: Fri, 7 Mar 2025 10:08:11 +0300 Subject: [PATCH] Sort strings naturally or alphabetically (#5075) Hidden setting. If true, use natural collection sorting matching the current behavior. If false, use conventional alphabetic sorting. --- chrome/content/zotero/xpcom/intl.js | 6 ++++-- defaults/preferences/zotero.js | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/xpcom/intl.js b/chrome/content/zotero/xpcom/intl.js index 81f8248820..900b57317f 100644 --- a/chrome/content/zotero/xpcom/intl.js +++ b/chrome/content/zotero/xpcom/intl.js @@ -244,12 +244,14 @@ Zotero.Intl = new function () { } function getLocaleCollation() { + var naturalSorting = Zotero.Prefs.get('naturalSorting'); + try { // DEBUG: Is this necessary, or will Intl.Collator just default to the same locales we're // passing manually? let locales = Services.locale.appLocalesAsBCP47; var collator = new Intl.Collator(locales, { - numeric: true, + numeric: naturalSorting, sensitivity: 'base' }); } @@ -260,7 +262,7 @@ Zotero.Intl = new function () { try { Zotero.logError("Falling back to en-US sorting"); collator = new Intl.Collator(['en-US'], { - numeric: true, + numeric: naturalSorting, sensitivity: 'base' }); } diff --git a/defaults/preferences/zotero.js b/defaults/preferences/zotero.js index 32ab40b7c7..62d3b42bba 100644 --- a/defaults/preferences/zotero.js +++ b/defaults/preferences/zotero.js @@ -38,6 +38,7 @@ pref("extensions.zotero.autoRenameFiles.fileTypes", "application/pdf,application pref("extensions.zotero.attachmentRenameTemplate", "{{ firstCreator suffix=\" - \" }}{{ year suffix=\" - \" }}{{ title truncate=\"100\" }}"); pref("extensions.zotero.capitalizeTitles", false); pref("extensions.zotero.launchNonNativeFiles", false); +pref("extensions.zotero.naturalSorting", true); pref("extensions.zotero.sortNotesChronologically", false); pref("extensions.zotero.sortNotesChronologically.reader", true); pref("extensions.zotero.sortAttachmentsChronologically", false);