ASP.NET Internationalization - global/shared resource key overrides
I am using ASP.NET resource internationalization.
I have the following structure
/App_LocalResources
Default.aspx.resx
/App_GlobalResources
Commmon.resx
Now what I was hoping for with ASP.Net resource is the ability override shared global keys within my local resource files.
For instance if in my Default.aspx page and I have the following:
<asp:Literal Text="<%$ Resources:FirstName %>" runat="server" />
And I have FirstName in both my global开发者_运维百科 resource file and local, I would expect the local key to override the shared but still fall through to global if it is not found in the local resource.
The problem I am finding is that being able to use the global resources requires that you provide the global resource filename.
<asp:Literal Text="<%$ Resources:Common,FirstName %>" runat="server" />
...which prevents you from being able to have a local override because of the explicit global filename declaration
I would hope there would be a way to specify a general key, and have it first search the local resources, and if not found there, then search through the global resources, without needing to specify a explicit global filename.
Is this possible, is there a way to attain this type of functionality from ASP.Net resources?
This just isn't the way resources work in .NET AFAIK - I believe your best bet is going to be encapsulating the resource access is a getter method which can attempt to match a local resource for a given key before falling back to the global. Not pretty though.
Of course there's always the option of creating and using your own ResourceManager but from experience that's much more pain than you think.
精彩评论