Browse Source

加入靜態方法讀取字串

kangkangtm 3 years ago
parent
commit
9ee4c3dd94
1 changed files with 16 additions and 1 deletions
  1. 16 1
      KdanStrings/Class1.cs

+ 16 - 1
KdanStrings/Class1.cs

@@ -3,10 +3,25 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using Windows.ApplicationModel.Resources;
 
 namespace KdanStrings
 {
-    public class Class1
+    public class Localized
     {
+        public string this[string key]
+        {
+            get
+            {
+                var str = ResourceLoader.GetForViewIndependentUse("KdanStrings/Resources").GetString(key);
+                return str;
+            }
+        }
+
+        public static string GetString(string key)
+        {
+            return ResourceLoader.GetForViewIndependentUse("KdanStrings/Resources").GetString(key);
+        }
     }
+
 }