[NUI.Gadget] Modify NUIGadgetResourceManager class (#5233)
authorhjhun <36876573+hjhun@users.noreply.github.com>
Tue, 2 May 2023 09:15:15 +0000 (18:15 +0900)
committerGitHub <noreply@github.com>
Tue, 2 May 2023 09:15:15 +0000 (18:15 +0900)
When getting the resource manager using the current culture info is failed,
the NUIGadgetResourceManager tries to get the resource manager using
the "default" string. It means using "/res/allowed/<resource>.dll" file.

Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/Tizen.NUI.Gadget/Tizen.NUI/NUIGadgetResourceManager.cs

index 79d7326..b2728a6 100755 (executable)
@@ -91,6 +91,14 @@ namespace Tizen.NUI
             var resourceManager = GetResourceManager(cultureInfo.Name);
             if (resourceManager == null)
             {
+                resourceManager = GetResourceManager("default");
+                if (resourceManager != null)
+                {
+#pragma warning disable CA1304
+                    return resourceManager.GetString(name);
+#pragma warning restore CA1304
+                }
+
                 if (cultureInfo.Name != "en")
                 {
                     resourceManager = GetResourceManager("en");
@@ -116,7 +124,16 @@ namespace Tizen.NUI
                 return resourceManager;
             }
 
-            string path = _resourcePath + locale + "/" + _resourceDll;
+            string path = string.Empty;
+            if (locale == "default")
+            {
+                path = _resourcePath + _resourceDll;
+            }
+            else
+            {
+                path = _resourcePath + locale + "/" + _resourceDll;
+            }
+
             if (!File.Exists(path))
             {
                 Log.Warn(path + " does not exist");
@@ -129,7 +146,12 @@ namespace Tizen.NUI
                 Assembly assembly = Assembly.Load(File.ReadAllBytes(path));
                 if (assembly != null)
                 {
-                    string baseName = _resourceClassName + "." + locale;
+                    string baseName = _resourceClassName;
+                    if (locale != "default")
+                    {
+                        baseName += "." + locale;
+                    }
+
                     resourceManager = new global::System.Resources.ResourceManager(baseName, assembly);
                     if (resourceManager == null)
                     {