diff --git a/src/Files.App/Extensions/MessageFormatExtensions.cs b/src/Files.App/Extensions/MessageFormatExtensions.cs index 04c74a871678..4698d0a26e85 100644 --- a/src/Files.App/Extensions/MessageFormatExtensions.cs +++ b/src/Files.App/Extensions/MessageFormatExtensions.cs @@ -25,11 +25,33 @@ public static class MessageFormatExtensions /// private static readonly CultureInfo _locale = new(AppLanguageHelper.PreferredLanguage.Code); + /// + /// Gets custom value formatters for the message formatter. + /// This class is used to customize the formatting of specific value types. + /// + private static readonly CustomValueFormatters _customFormatter = new() + { + // Custom formatting for number values. + Number = (CultureInfo _, object? value, string? style, out string? formatted) => + { + if (style is not null && style == string.Empty) + { + // Format the number '{0, number}' + formatted = string.Format($"{{0:#,##0}}", value); + return true; + } + + formatted = null; + return false; + } + }; + /// /// Message formatter with caching enabled, using the current UI culture's two-letter ISO language name. - /// It is initialized with the options to use cache and the two-letter ISO language name of the current UI culture. + /// It is initialized with the options to use cache and the two-letter ISO language name of the current UI culture, + /// and a custom value formatter for number values. /// - private static readonly MessageFormatter _formatter = new(useCache: true, locale: _locale.TwoLetterISOLanguageName); + private static readonly MessageFormatter _formatter = new(useCache: true, locale: _locale.TwoLetterISOLanguageName, customValueFormatter: _customFormatter); /// /// Creates a dictionary for format pairs with a string key.