Add option to sort base on certain locale. (#1818)

* Add support for localized sorting

* Switch go-locale module; Use collate option for natural sorting

* Doc and error message improvement

* Simplify predicated checking of localized sorting.

* Improve error handling of `set locale` command
This commit is contained in:
陆离 authored and GitHub committed 2024-11-02 00:12:21 +11:00
1 parent 4079aead14
commit 3f63bc980f
8 files changed
+189 -19

No files matched your search

+10 -1
View File
@@ -169,6 +169,7 @@ The following options can be used to customize the behavior of lf:
info []string (default '')
infotimefmtnew string (default 'Jan _2 15:04')
infotimefmtold string (default 'Jan _2 2006')
locale string (default '')
mouse bool (default false)
number bool (default false)
numberfmt string (default "\033[33m")
@@ -823,6 +824,14 @@ Format string of the file time shown in the info column when it matches this yea
Format string of the file time shown in the info column when it doesn't match this year.
## locale (string) (default `''`)
An IETF BCP 47 language tag (e.g. `zh-CN`) for specifying the locale used when using sort type
`natural` and `name`.
An empty string means disable locale ordering, and the special value `'*'` is used
to indicate reading the locale setting from the system environment.
## mouse (bool) (default false)
Send mouse events as input.
@@ -1184,7 +1193,7 @@ Command `set` is used to set an option which can be a boolean, integer, or strin
set sortby "time" # string value with double quotes (backslash escapes)
Command `setlocal` is used to set a local option for a directory which can be a boolean or string.
Currently supported local options are `dirfirst`, `dironly`, `hidden`, `info`, `reverse`, and `sortby`.
Currently supported local options are `dirfirst`, `dironly`, `hidden`, `info`, `reverse`, `sortby` and `locale`.
Adding a trailing path separator (i.e. `/` for Unix and `\` for Windows) sets the option for the given directory along with its subdirectories:
setlocal /foo/bar hidden # boolean enable