[Applications.Common] Fix getting default locale (#4965)
authorhjhun <36876573+hjhun@users.noreply.github.com>
Fri, 3 Feb 2023 08:24:49 +0000 (17:24 +0900)
committerGitHub <noreply@github.com>
Fri, 3 Feb 2023 08:24:49 +0000 (17:24 +0900)
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/Tizen.Applications.Common/Interop/Interop.Libc.cs
src/Tizen.Applications.Common/Tizen.Applications/CoreApplication.cs

index 55d23c9..81aacdd 100644 (file)
@@ -26,6 +26,9 @@ internal static partial class Interop
         [DllImport(Libraries.Libc, EntryPoint = "free", CallingConvention = CallingConvention.Cdecl)]
         internal static extern int Free(IntPtr ptr);
 
+        [DllImport(Libraries.Libc, EntryPoint = "getenv")]
+        internal static extern IntPtr GetEnvironmentVariable(string name);
+
         [NativeStruct("struct timespec", Include = "time.h")]
         [StructLayout(LayoutKind.Sequential)]
         internal struct TimeStamp
index 0e83f37..c9725ae 100644 (file)
@@ -595,12 +595,7 @@ namespace Tizen.Applications
 
         internal static string GetDefaultLocale()
         {
-            IntPtr stringPtr = IntPtr.Zero;
-            if (Interop.BaseUtilsi18n.GetDefault(out stringPtr) != 0)
-            {
-                return string.Empty;
-            }
-
+            IntPtr stringPtr = Interop.Libc.GetEnvironmentVariable("LANG");
             if (stringPtr == IntPtr.Zero)
             {
                 return string.Empty;