mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 11:55:55 +02:00
Respect system locale when formatting file sizes via config (#15271)
# Description Commands and other pieces of code using `$env.config.format.filesize` to format filesizes now respect the system locale when formatting the numeric portion of a file size. # User-Facing Changes - System locale is respected when using `$env.config.format.filesize` to format file sizes. - Formatting a file size with a binary unit is now exact for large file sizes and units. - The output of `to text` is no longer dependent on the config.
This commit is contained in:
@ -22,9 +22,16 @@ pub fn get_system_locale() -> Locale {
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
pub fn get_system_locale_string() -> Option<String> {
|
||||
std::env::var(LOCALE_OVERRIDE_ENV_VAR)
|
||||
.ok()
|
||||
.or_else(sys_locale::get_locale)
|
||||
std::env::var(LOCALE_OVERRIDE_ENV_VAR).ok().or_else(
|
||||
#[cfg(not(test))]
|
||||
{
|
||||
sys_locale::get_locale
|
||||
},
|
||||
#[cfg(test)]
|
||||
{
|
||||
|| Some(Locale::en_US_POSIX.name().to_owned())
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(not(debug_assertions))]
|
||||
|
Reference in New Issue
Block a user