[Application.Common] Fix ULocale class (#1357)
authorhjhun <36876573+hjhun@users.noreply.github.com>
Tue, 4 Feb 2020 04:38:14 +0000 (13:38 +0900)
committerGitHub <noreply@github.com>
Tue, 4 Feb 2020 04:38:13 +0000 (13:38 +0900)
- Uses base-utils-i18n instead of icu

Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/Tizen.Applications.Common/Interop/Interop.BaseUtilsi18n.cs [moved from src/Tizen.Applications.Common/Interop/Interop.Icu.cs with 66% similarity, mode: 0755]
src/Tizen.Applications.Common/Interop/Interop.Libraries.cs
src/Tizen.Applications.Common/Tizen.Applications/CoreApplication.cs

old mode 100644 (file)
new mode 100755 (executable)
similarity index 66%
rename from src/Tizen.Applications.Common/Interop/Interop.Icu.cs
rename to src/Tizen.Applications.Common/Interop/Interop.BaseUtilsi18n.cs
index d5771c4..f2c6e01
@@ -23,21 +23,21 @@ using Tizen.Applications;
 
 internal static partial class Interop
 {
-    internal static partial class Icu
+    internal static partial class BaseUtilsi18n
     {
-        [DllImport(Libraries.Icuuc, EntryPoint = "uloc_canonicalize")]
-        internal static extern Int32 Canonicalize(string localeID, [Out] StringBuilder name, Int32 nameCapacity, out int err);
+        [DllImport(Libraries.BaseUtilsi18n, EntryPoint = "i18n_ulocale_canonicalize")]
+        internal static extern Int32 Canonicalize(string localeID, [Out] StringBuilder name, Int32 nameCapacity);
 
-        [DllImport(Libraries.Icuuc, EntryPoint = "uloc_getLanguage")]
-        internal static extern Int32 GetLanguage(string localeID, [Out] StringBuilder language, Int32 languageCapacity, out int err);
+        [DllImport(Libraries.BaseUtilsi18n, EntryPoint = "i18n_ulocale_get_language")]
+        internal static extern Int32 GetLanguage(string localeID, [Out] StringBuilder language, Int32 languageCapacity, out int bufSizeLanguage);
 
-        [DllImport(Libraries.Icuuc, EntryPoint = "uloc_getScript")]
-        internal static extern Int32 GetScript(string localeID, [Out] StringBuilder script, Int32 scriptCapacity, out int err);
+        [DllImport(Libraries.BaseUtilsi18n, EntryPoint = "i18n_ulocale_get_script")]
+        internal static extern Int32 GetScript(string localeID, [Out] StringBuilder script, Int32 scriptCapacity);
 
-        [DllImport(Libraries.Icuuc, EntryPoint = "uloc_getCountry")]
+        [DllImport(Libraries.BaseUtilsi18n, EntryPoint = "i18n_ulocale_get_country")]
         internal static extern Int32 GetCountry(string localeID, [Out] StringBuilder country, Int32 countryCapacity, out int err);
 
-        [DllImport(Libraries.Icuuc, EntryPoint = "uloc_getVariant")]
-        internal static extern Int32 GetVariant(string localeID, [Out] StringBuilder variant, Int32 variantCapacity, out int err);
+        [DllImport(Libraries.BaseUtilsi18n, EntryPoint = "i18n_ulocale_get_variant")]
+        internal static extern Int32 GetVariant(string localeID, [Out] StringBuilder variant, Int32 variantCapacity);
     }
 }
index 1949f62..000e034 100755 (executable)
@@ -27,7 +27,7 @@ internal static partial class Interop
         public const string Glib = "libglib-2.0.so.0";
         public const string Libc = "libc.so.6";
         public const string Application = "libcapi-appfw-application.so.0";
-        public const string Icuuc = "libicuuc.so";
+        public const string BaseUtilsi18n = "libbase-utils-i18n.so.0";
         public const string RpcPort = "librpc-port.so.1";
     }
 }
index a173a0f..0e3ba9b 100755 (executable)
@@ -327,12 +327,11 @@ namespace Tizen.Applications
 
     internal class ULocale
     {
-        private const int ICU_ULOC_FULLNAME_CAPACITY = 157;
-        private const int ICU_ULOC_LANG_CAPACITY = 12;
-        private const int ICU_ULOC_SCRIPT_CAPACITY = 6;
-        private const int ICU_ULOC_COUNTRY_CAPACITY = 4;
-        private const int ICU_ULOC_VARIANT_CAPACITY = ICU_ULOC_FULLNAME_CAPACITY;
-        private const int ICU_U_ZERO_ERROR = 0;
+        private const int ULOC_FULLNAME_CAPACITY = 157;
+        private const int ULOC_LANG_CAPACITY = 12;
+        private const int ULOC_SCRIPT_CAPACITY = 6;
+        private const int ULOC_COUNTRY_CAPACITY = 4;
+        private const int ULOC_VARIANT_CAPACITY = ULOC_FULLNAME_CAPACITY;
 
         internal ULocale(string locale)
         {
@@ -351,11 +350,9 @@ namespace Tizen.Applications
 
         private string Canonicalize(string localeName)
         {
-            int err = ICU_U_ZERO_ERROR;
-
             // Get the locale name from ICU
-            StringBuilder sb = new StringBuilder(ICU_ULOC_FULLNAME_CAPACITY);
-            if (Interop.Icu.Canonicalize(localeName, sb, sb.Capacity, out err) <= 0)
+            StringBuilder sb = new StringBuilder(ULOC_FULLNAME_CAPACITY);
+            if (Interop.BaseUtilsi18n.Canonicalize(localeName, sb, sb.Capacity) <= 0)
             {
                 return null;
             }
@@ -365,11 +362,9 @@ namespace Tizen.Applications
 
         private string GetLanguage(string locale)
         {
-            int err = ICU_U_ZERO_ERROR;
-
             // Get the language name from ICU
-            StringBuilder sb = new StringBuilder(ICU_ULOC_LANG_CAPACITY);
-            if (Interop.Icu.GetLanguage(locale, sb, sb.Capacity, out err) <= 0)
+            StringBuilder sb = new StringBuilder(ULOC_LANG_CAPACITY);
+            if (Interop.BaseUtilsi18n.GetLanguage(locale, sb, sb.Capacity, out int bufSizeLanguage) != 0)
             {
                 return null;
             }
@@ -379,11 +374,9 @@ namespace Tizen.Applications
 
         private string GetScript(string locale)
         {
-            int err = ICU_U_ZERO_ERROR;
-
             // Get the script name from ICU
-            StringBuilder sb = new StringBuilder(ICU_ULOC_SCRIPT_CAPACITY);
-            if (Interop.Icu.GetScript(locale, sb, sb.Capacity, out err) <= 0)
+            StringBuilder sb = new StringBuilder(ULOC_SCRIPT_CAPACITY);
+            if (Interop.BaseUtilsi18n.GetScript(locale, sb, sb.Capacity) <= 0)
             {
                 return null;
             }
@@ -393,11 +386,11 @@ namespace Tizen.Applications
 
         private string GetCountry(string locale)
         {
-            int err = ICU_U_ZERO_ERROR;
+            int err = 0;
 
             // Get the country name from ICU
-            StringBuilder sb = new StringBuilder(ICU_ULOC_SCRIPT_CAPACITY);
-            if (Interop.Icu.GetCountry(locale, sb, sb.Capacity, out err) <= 0)
+            StringBuilder sb = new StringBuilder(ULOC_SCRIPT_CAPACITY);
+            if (Interop.BaseUtilsi18n.GetCountry(locale, sb, sb.Capacity, out err) <= 0)
             {
                 return null;
             }
@@ -407,11 +400,9 @@ namespace Tizen.Applications
 
         private string GetVariant(string locale)
         {
-            int err = ICU_U_ZERO_ERROR;
-
             // Get the variant name from ICU
-            StringBuilder sb = new StringBuilder(ICU_ULOC_VARIANT_CAPACITY);
-            if (Interop.Icu.GetVariant(locale, sb, sb.Capacity, out err) <= 0)
+            StringBuilder sb = new StringBuilder(ULOC_VARIANT_CAPACITY);
+            if (Interop.BaseUtilsi18n.GetVariant(locale, sb, sb.Capacity) <= 0)
             {
                 return null;
             }