@@ -11,13 +11,13 @@ namespace CommunityToolkit.WinUI
11
11
/// </summary>
12
12
public static class StringExtensions
13
13
{
14
- private static readonly ResourceLoader Loader ;
14
+ private static readonly ResourceManager ResourceManager ;
15
15
16
16
static StringExtensions ( )
17
17
{
18
18
try
19
19
{
20
- Loader = new ResourceLoader ( ) ;
20
+ ResourceManager = new ResourceManager ( ) ;
21
21
}
22
22
catch
23
23
{
@@ -47,7 +47,7 @@ public static string GetViewLocalized(this string resourceKey, UIContext uiConte
47
47
/// <returns>string value for given resource or empty string if not found.</returns>
48
48
public static string GetLocalized ( this string resourceKey )
49
49
{
50
- return Loader ? . GetString ( resourceKey ) ;
50
+ return ResourceManager . MainResourceMap . TryGetValue ( resourceKey ) ? . ValueAsString ;
51
51
}
52
52
53
53
/*
@@ -75,11 +75,20 @@ public static string GetLocalized(this string resourceKey, UIContext uiContext)
75
75
public static string GetLocalized ( this string resourceKey , string resourcePath )
76
76
{
77
77
// Try and retrieve resource at app level first.
78
- var result = Loader ? . GetString ( resourceKey ) ;
78
+ var result = ResourceManager . MainResourceMap . TryGetValue ( resourceKey ) ? . ValueAsString ;
79
79
80
80
if ( string . IsNullOrEmpty ( result ) )
81
81
{
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
+ }
83
92
}
84
93
85
94
return result ;
0 commit comments