Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seed --locale with LC_COLLATE/LC_ALL/LANGUAGE/LANG environment variables #37

Open
jmaargh opened this issue Mar 23, 2023 · 1 comment
Open

Comments

@jmaargh
Copy link

jmaargh commented Mar 23, 2023

Hey, just read your interesting blog post about sorting. In case you weren't already aware, there's already a well-supported way for programs to be locale-aware on Linux: a set of environment variables, the main one being LANG.

The full list is here, but there's also LC_COLLATE which is specifically for "sorting and regular expressions". If you are so inclined, I'd suggest parsing these variables and using them in the appropriate priority order (see the linked page). Personally at that point I'd remove the --locale flag altogether, but you could also leave it in as an override.

@sts10
Copy link
Owner

sts10 commented Mar 23, 2023

Oh, this is helpful.

I think I've gotten some of the benefits with this commit: 157141f . Basically, if user does not specify a --locale, the program will attempt to read the LANG environmental variable (rather than default to en-US). If the program can't read LANG, it then uses en-US.

I'll try to figure out how to use LC_COLLATE soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants