Procházet zdrojové kódy

Use CurrentCulture instead of CurrentUICulture.

Use `CurrentCulture` instead of `CurrentUICulture` in converters etc. `CurrentUICulture` should be used for translations, `CurrentCulture` should be used for things like numbers, dates etc.
Steven Kirk před 8 roky
rodič
revize
78bb593f97

+ 1 - 1
src/Markup/Avalonia.Markup.Xaml/Data/MultiBinding.cs

@@ -102,7 +102,7 @@ namespace Avalonia.Markup.Xaml.Data
 
         private object ConvertValue(IList<object> values, Type targetType)
         {
-            var converted = Converter.Convert(values, targetType, null, CultureInfo.CurrentUICulture);
+            var converted = Converter.Convert(values, targetType, null, CultureInfo.CurrentCulture);
 
             if (converted == AvaloniaProperty.UnsetValue && FallbackValue != null)
             {

+ 2 - 2
src/Markup/Avalonia.Markup/Data/BindingExpression.cs

@@ -122,7 +122,7 @@ namespace Avalonia.Markup.Data
                         value,
                         type,
                         ConverterParameter,
-                        CultureInfo.CurrentUICulture);
+                        CultureInfo.CurrentCulture);
 
                     if (converted == AvaloniaProperty.UnsetValue)
                     {
@@ -186,7 +186,7 @@ namespace Avalonia.Markup.Data
                     value,
                     _targetType,
                     ConverterParameter,
-                    CultureInfo.CurrentUICulture);
+                    CultureInfo.CurrentCulture);
 
                 notification = converted as BindingNotification;
 

+ 6 - 6
tests/Avalonia.UnitTests/InvariantCultureFixture.cs

@@ -21,20 +21,20 @@ namespace Avalonia.UnitTests
         public InvariantCultureFixture()
         {
 #if NET461
-            _restore = Thread.CurrentThread.CurrentUICulture;
-            Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
+            _restore = Thread.CurrentThread.CurrentCulture;
+            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
 #else
-            _restore = CultureInfo.CurrentUICulture;
-            CultureInfo.CurrentUICulture = CultureInfo.CurrentCulture = CultureInfo.InvariantCulture;
+            _restore = CultureInfo.CurrentCulture;
+            CultureInfo.CurrentCulture = CultureInfo.InvariantCulture;
 #endif
         }
 
         public void Dispose()
         {
 #if NET461
-            Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture = _restore;
+            Thread.CurrentThread.CurrentCulture = _restore;
 #else
-            CultureInfo.CurrentUICulture = CultureInfo.CurrentCulture = _restore;
+            CultureInfo.CurrentCulture = _restore;
 #endif
         }
     }