ardaku / whoami

Rust crate to get the current user and environment.
Apache License 2.0
195 stars 31 forks source link

Language Handling #60

Open AldaronLau opened 1 year ago

AldaronLau commented 1 year ago

Currently, on Unix-like platforms for English speakers in the US, something along the lines of ["en-US", "en"] will be reported by lang(). On Windows, just ["en-US"] will be reported. How should language fallbacks be expected to be handled? It would be nice to have some kind of consistency here.

AldaronLau commented 1 year ago

Not sure on exact language tags, but for example, if the user prefers ["en-CN", "en-GB", "zh-CN"], then I'm assuming that if all else fails, they would prefer next (for fallback) ["en", "zh"] (requesting any dialect for English first, then any dialect of Chinese second). But, the question is whether or not whoami should append these any dialect language codes?

AldaronLau commented 1 year ago

I think the answer to this question depends on whether or not it's supported to select "any" dialect from the OS dialogues (needs some research).

AldaronLau commented 1 year ago

Upon further research it appears as though it's possible to select "any", at least on Linux. WhoAmI should not automatically insert the language without the dialect. Although, since it is a fallback list, any dialect could be appended at the end of the list:

["en-CN", "en-GB", "zh-CN"] -> ["en-CN", "en-GB", "zh-CN", "en", "zh"]
["en-CN", "en", "zh-CN"] -> ["en-CN", "en", "zh-CN", "zh"]