* Use `localectl list-locales` if possible.
* Otherwise list `/usr/lib/locale` and try to use `localedef` to list
`/usr/lib/locale/locale-archive`.
* Do not bother with `/usr/share/locale` as, it turns out, it is only used
for localisations by third-party programs on Linux. Strangely, macOS
seems to have actual locale definitions in there, but this tool is
mostly aimed at Linux, since macOS installations are pretty uniform.
Previously the code was using stdout for testing the terminal detection
functionality. However, there is no guarantee that the tests will always
be running with stdout attached to a terminal.
Create a fresh pseudo-terminal instead and use it instead of stdout.