csharp: Localization strings with CultureInfo.
authorBruno da Silva Belo <bruno.belo@expertisesolutions.com.br>
Fri, 8 Nov 2019 02:33:09 +0000 (23:33 -0300)
committerWonki Kim <wonki_.kim@samsung.com>
Mon, 11 Nov 2019 02:20:43 +0000 (11:20 +0900)
Summary: ref T8404

Reviewers: lauromoura, felipealmeida, YOhoho

Reviewed By: lauromoura

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Maniphest Tasks: T8404

Differential Revision: https://phab.enlightenment.org/D10608

src/bindings/mono/eina_mono/eina_container_common.cs
src/bindings/mono/eina_mono/eina_value.cs
src/tests/efl_mono/Strings.cs

index 5b3b2f4..7b94ab7 100644 (file)
@@ -21,6 +21,7 @@ using System.Runtime.InteropServices;
 using System.Collections.Generic;
 using System.Reflection;
 using System.ComponentModel;
+using System.Globalization;
 
 using Eina.Callbacks;
 using static Eina.HashNativeFunctions;
@@ -642,7 +643,7 @@ abstract public class Primitive32ElementTraits<T> : PrimitiveElementTraits<T>, I
 
     public IntPtr ManagedToNativeAllocRef(T man, bool refs)
     {
-        return int32Traits.ManagedToNativeAlloc(Convert.ToInt32((object)man));
+        return int32Traits.ManagedToNativeAlloc(Convert.ToInt32((object)man, CultureInfo.CurrentCulture));
     }
 
     public void NativeFreeRef(IntPtr nat, bool unrefs)
@@ -681,7 +682,7 @@ abstract public class Primitive64ElementTraits<T> : PrimitiveElementTraits<T>, I
 
     public IntPtr ManagedToNativeAllocRef(T man, bool refs)
     {
-        return int64Traits.ManagedToNativeAlloc(Convert.ToInt64((object)man));
+        return int64Traits.ManagedToNativeAlloc(Convert.ToInt64((object)man, CultureInfo.CurrentCulture));
     }
 
     public void NativeFreeRef(IntPtr nat, bool unrefs)
index 8e0d836..365d60b 100644 (file)
@@ -26,6 +26,7 @@ using System.Security.Permissions;
 using System.Security;
 using System.Diagnostics.CodeAnalysis;
 using System.Runtime.Serialization;
+using System.Globalization;
 
 using static Eina.EinaNative.UnsafeNativeMethods;
 using static Eina.TraitFunctions;
@@ -3111,69 +3112,69 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
         {
             case ValueType.SByte:
                 {
-                    sbyte b = Convert.ToSByte(o);
+                    sbyte b = Convert.ToSByte(o, CultureInfo.CurrentCulture);
                     return eina_value_container_append_wrapper_char(this.Handle, b);
                 }
 
             case ValueType.Byte:
                 {
-                    byte b = Convert.ToByte(o);
+                    byte b = Convert.ToByte(o, CultureInfo.CurrentCulture);
                     return eina_value_container_append_wrapper_uchar(this.Handle, b);
                 }
 
             case ValueType.Short:
                 {
-                    short b = Convert.ToInt16(o);
+                    short b = Convert.ToInt16(o, CultureInfo.CurrentCulture);
                     return eina_value_container_append_wrapper_short(this.Handle, b);
                 }
 
             case ValueType.UShort:
                 {
-                    ushort b = Convert.ToUInt16(o);
+                    ushort b = Convert.ToUInt16(o, CultureInfo.CurrentCulture);
                     return eina_value_container_append_wrapper_ushort(this.Handle, b);
                 }
 
             case ValueType.Int32:
                 {
-                    int x = Convert.ToInt32(o);
+                    int x = Convert.ToInt32(o, CultureInfo.CurrentCulture);
                     return eina_value_container_append_wrapper_int(this.Handle, x);
                 }
 
             case ValueType.UInt32:
                 {
-                    uint x = Convert.ToUInt32(o);
+                    uint x = Convert.ToUInt32(o, CultureInfo.CurrentCulture);
                     return eina_value_container_append_wrapper_uint(this.Handle, x);
                 }
 
             case ValueType.Long:
             case ValueType.Int64:
                 {
-                    long x = Convert.ToInt64(o);
+                    long x = Convert.ToInt64(o, CultureInfo.CurrentCulture);
                     return eina_value_container_append_wrapper_long(this.Handle, x);
                 }
 
             case ValueType.ULong:
             case ValueType.UInt64:
                 {
-                    ulong x = Convert.ToUInt64(o);
+                    ulong x = Convert.ToUInt64(o, CultureInfo.CurrentCulture);
                     return eina_value_container_append_wrapper_ulong(this.Handle, x);
                 }
 
             case ValueType.Float:
                 {
-                    float x = Convert.ToSingle(o);
+                    float x = Convert.ToSingle(o, CultureInfo.CurrentCulture);
                     return eina_value_container_append_wrapper_float(this.Handle, x);
                 }
 
             case ValueType.Double:
                 {
-                    double x = Convert.ToDouble(o);
+                    double x = Convert.ToDouble(o, CultureInfo.CurrentCulture);
                     return eina_value_container_append_wrapper_double(this.Handle, x);
                 }
 
             case ValueType.String:
                 {
-                    string x = Convert.ToString(o);
+                    string x = Convert.ToString(o, CultureInfo.CurrentCulture);
                     return eina_value_container_append_wrapper_string(this.Handle, x);
                 }
             case ValueType.Object:
@@ -3298,42 +3299,48 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
             {
                 case ValueType.SByte:
                     {
-                        sbyte v = Convert.ToSByte(value);
+                        sbyte v = Convert.ToSByte(value,
+                                                  CultureInfo.CurrentCulture);
                         eina_value_container_set_wrapper_char(this.Handle, i, v);
                         break;
                     }
 
                 case ValueType.Byte:
                     {
-                        byte v = Convert.ToByte(value);
+                        byte v = Convert.ToByte(value,
+                                                CultureInfo.CurrentCulture);
                         eina_value_container_set_wrapper_uchar(this.Handle, i, v);
                         break;
                     }
 
                 case ValueType.Short:
                     {
-                        short x = Convert.ToInt16(value);
+                        short x = Convert.ToInt16(value,
+                                                  CultureInfo.CurrentCulture);
                         eina_value_container_set_wrapper_short(this.Handle, i, x);
                         break;
                     }
 
                 case ValueType.UShort:
                     {
-                        ushort x = Convert.ToUInt16(value);
+                        ushort x = Convert.ToUInt16(value,
+                                                    CultureInfo.CurrentCulture);
                         eina_value_container_set_wrapper_ushort(this.Handle, i, x);
                         break;
                     }
 
                 case ValueType.Int32:
                     {
-                        int x = Convert.ToInt32(value);
+                        int x = Convert.ToInt32(value,
+                                                CultureInfo.CurrentCulture);
                         eina_value_container_set_wrapper_int(this.Handle, i, x);
                         break;
                     }
 
                 case ValueType.UInt32:
                     {
-                        uint x = Convert.ToUInt32(value);
+                        uint x = Convert.ToUInt32(value,
+                                                  CultureInfo.CurrentCulture);
                         eina_value_container_set_wrapper_uint(this.Handle, i, x);
                         break;
                     }
@@ -3341,7 +3348,8 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
                 case ValueType.Long:
                 case ValueType.Int64:
                     {
-                        long x = Convert.ToInt64(value);
+                        long x = Convert.ToInt64(value,
+                                                 CultureInfo.CurrentCulture);
                         eina_value_container_set_wrapper_long(this.Handle, i, x);
                         break;
                     }
@@ -3349,28 +3357,31 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
                 case ValueType.ULong:
                 case ValueType.UInt64:
                     {
-                        ulong x = Convert.ToUInt64(value);
+                        ulong x = Convert.ToUInt64(value,
+                                                   CultureInfo.CurrentCulture);
                         eina_value_container_set_wrapper_ulong(this.Handle, i, x);
                         break;
                     }
 
                 case ValueType.Float:
                     {
-                        float x = Convert.ToSingle(value);
+                        float x = Convert.ToSingle(value,
+                                                   CultureInfo.CurrentCulture);
                         eina_value_container_set_wrapper_float(this.Handle, i, x);
                         break;
                     }
 
                 case ValueType.Double:
                     {
-                        double x = Convert.ToDouble(value);
+                        double x = Convert.ToDouble(value, CultureInfo.CurrentCulture);
                         eina_value_container_set_wrapper_double(this.Handle, i, x);
                         break;
                     }
 
                 case ValueType.String:
                     {
-                        string x = Convert.ToString(value);
+                        string x = Convert.ToString(value,
+                                                    CultureInfo.CurrentCulture);
                         eina_value_container_set_wrapper_string(this.Handle, i, x);
                         break;
                     }
index dc5bd08..43c6717 100644 (file)
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 using System;
+using System.Globalization;
 
 namespace TestSuite {
 
@@ -83,7 +84,8 @@ class TestStrings
             String str = String.Empty;
             var obj = new Dummy.TestObject();
             obj.OutOwnString(out str);
-            Test.AssertEquals(str.ToString(), "out_own_string");
+            Test.AssertEquals(str.ToString(CultureInfo.CurrentCulture),
+                              "out_own_string");
         }
         System.GC.Collect();
     }
@@ -254,7 +256,8 @@ class TestStringshare
             String str = String.Empty;
             var obj = new Dummy.TestObject();
             obj.OutOwnStringshare(out str);
-            Test.AssertEquals(str.ToString(), "out_own_stringshare");
+            Test.AssertEquals(str.ToString(CultureInfo.CurrentCulture),
+                              "out_own_stringshare");
         }
         System.GC.Collect();
     }