mirror of
https://fastgit.cc/github.com/sourcegit-scm/sourcegit
synced 2026-04-22 13:51:15 +08:00
ux: format file size based on current culture
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Reflection;
|
||||
@@ -194,6 +195,17 @@ namespace SourceGit
|
||||
if (app._activeLocale != null)
|
||||
app.Resources.MergedDictionaries.Remove(app._activeLocale);
|
||||
|
||||
try
|
||||
{
|
||||
var culture = CultureInfo.GetCultureInfo(localeKey.Replace("_", "-"));
|
||||
Thread.CurrentThread.CurrentUICulture = culture;
|
||||
Thread.CurrentThread.CurrentCulture = culture;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Just ignore
|
||||
}
|
||||
|
||||
app.Resources.MergedDictionaries.Add(targetLocale);
|
||||
app._activeLocale = targetLocale;
|
||||
}
|
||||
|
||||
@@ -7,15 +7,15 @@ namespace SourceGit.Converters
|
||||
public static readonly FuncValueConverter<long, string> ToFileSize = new(bytes =>
|
||||
{
|
||||
if (bytes < KB)
|
||||
return $"{bytes} B";
|
||||
return $"{bytes:N0} B";
|
||||
|
||||
if (bytes < MB)
|
||||
return $"{(bytes / KB):F3} KB ({bytes} B)";
|
||||
return $"{(bytes / KB):N3} KB ({bytes:N0})";
|
||||
|
||||
if (bytes < GB)
|
||||
return $"{(bytes / MB):F3} MB ({bytes} B)";
|
||||
return $"{(bytes / MB):N3} MB ({bytes:N0})";
|
||||
|
||||
return $"{(bytes / GB):F3} GB ({bytes} B)";
|
||||
return $"{(bytes / GB):N3} GB ({bytes:N0})";
|
||||
});
|
||||
|
||||
private const double KB = 1024;
|
||||
|
||||
Reference in New Issue
Block a user