@@ -11,13 +11,13 @@ namespace CommunityToolkit.WinUI
1111 /// </summary>
1212 public static class StringExtensions
1313 {
14- private static readonly ResourceLoader Loader ;
14+ private static readonly ResourceManager ResourceManager ;
1515
1616 static StringExtensions ( )
1717 {
1818 try
1919 {
20- Loader = new ResourceLoader ( ) ;
20+ ResourceManager = new ResourceManager ( ) ;
2121 }
2222 catch
2323 {
@@ -47,7 +47,7 @@ public static string GetViewLocalized(this string resourceKey, UIContext uiConte
4747 /// <returns>string value for given resource or empty string if not found.</returns>
4848 public static string GetLocalized ( this string resourceKey )
4949 {
50- return Loader ? . GetString ( resourceKey ) ;
50+ return ResourceManager . MainResourceMap . TryGetValue ( resourceKey ) ? . ValueAsString ;
5151 }
5252
5353 /*
@@ -75,11 +75,20 @@ public static string GetLocalized(this string resourceKey, UIContext uiContext)
7575 public static string GetLocalized ( this string resourceKey , string resourcePath )
7676 {
7777 // Try and retrieve resource at app level first.
78- var result = Loader ? . GetString ( resourceKey ) ;
78+ var result = ResourceManager . MainResourceMap . TryGetValue ( resourceKey ) ? . ValueAsString ;
7979
8080 if ( string . IsNullOrEmpty ( result ) )
8181 {
82- result = new ResourceLoader ( ResourceLoader . GetDefaultResourceFilePath ( ) , resourcePath ) . GetString ( resourceKey ) ;
82+ var manager = new ResourceManager ( ) ;
83+ var subTree = manager . MainResourceMap . TryGetSubtree ( resourcePath ) ;
84+ if ( subTree != null )
85+ {
86+ var r = subTree . TryGetValue ( resourceKey ) ;
87+ if ( r != null )
88+ {
89+ result = r . ValueAsString ;
90+ }
91+ }
8392 }
8493
8594 return result ;
0 commit comments