So I've implement a custom ResourceProvider and ResourceManager. It's actually working correctly, however, I'm a little confused why the the IResourceProvider.GetObject() method always receives an Invariant culture.
object value = this.ResourceManager.GetObject(resourceKey,culture);
return value;
}
On a page that has its UICulture set I can see the GetObject method firing twice for each object (looks like once for precompilation and once for the actual page access. But in both cases the culture is Invariant even though the page's culture is specific
to the user.
It all works anyway - so it looks like the ResourceManager implementation manages to handle the Resource Fallback automatically using the CurrentUICulture instead of the Invariant Culture passed in. Which strikes me as really odd. If I ask the resource manager
for the Invariant culture - it should give me that, but instead it's returning the currentUI culture if there's an entry for it.
What the heck is going on here?
I have no code that retrieves this data on its own - I simply have a ResourceManager and ResourceReader implementation that provides a ResourceSet and this obviously works since otherwise the data is being fed properly.The resource reader and manager are
managing all of this, but what's the point of the culture parameter if the culture is not actually passed?
rstrahl
Contributor
2095 Points
366 Posts
ASPInsiders
MVP
IResourceProvider.GetObject() - Culture is always Invariant
Oct 06, 2006 10:39 AM|LINK
So I've implement a custom ResourceProvider and ResourceManager. It's actually working correctly, however, I'm a little confused why the the IResourceProvider.GetObject() method always receives an Invariant culture.
object IResourceProvider.GetObject(string resourceKey, CultureInfo culture)
{
object value = this.ResourceManager.GetObject(resourceKey,culture);
return value;
}
On a page that has its UICulture set I can see the GetObject method firing twice for each object (looks like once for precompilation and once for the actual page access. But in both cases the culture is Invariant even though the page's culture is specific to the user.
It all works anyway - so it looks like the ResourceManager implementation manages to handle the Resource Fallback automatically using the CurrentUICulture instead of the Invariant Culture passed in. Which strikes me as really odd. If I ask the resource manager for the Invariant culture - it should give me that, but instead it's returning the currentUI culture if there's an entry for it.
What the heck is going on here?
I have no code that retrieves this data on its own - I simply have a ResourceManager and ResourceReader implementation that provides a ResourceSet and this obviously works since otherwise the data is being fed properly.The resource reader and manager are managing all of this, but what's the point of the culture parameter if the culture is not actually passed?
+++ Rick --
West Wind Technologies
Making waves on the Web
www.west-wind.com/weblog