I have a lot of local resourse files
I want to add another language and I do not want to go through all folders and add SomeControl.ascx.de.resx files for example and then have to recompile the whole think.
I would like to use satellite assemblies and embed all the files into something like MyWebPage.de.dll
This was possible in VS2003 version for global resources, but I'm not sure can I do it in VS2008 version for local resources?
I am accessing the resource with the syntax:
<asp:label id="lblSomething" runat="server" meta:resourcekey="labelFirstName"/>
A satellite assembly is a . NET Framework assembly containing resources specific to a given language. Using satellite assemblies, you can place resources for different languages in different assemblies, and the correct assembly is loaded into memory only if the user selects to view the application in that language.
A satellite assembly is a compiled library (DLL) that contains “localizable” resources specific to a given culture such as strings, bitmaps, etc. You are likely to use satellite assemblies when creating a multilingual UI application.
Your question isn't really too clear on whether you are looking for a feature of VS2008 or a feature of the ASP.NET framework. So I'll go with the code solution.
The implicit binding syntax you're using uses ASP.NET's default LocalResourceProvider which takes in the path of page under which the resources live to work out which resources to load. If your resources are stored elsewhere and you still want to use the implicit binding systax in your code in front you'll need to use your own Provider. Sounds complicated but it's fairly straightforward.
To do this you'll need to first subclass ResourceProviderFactory
and override both
IResourceProvider CreateGlobalResourceProvider(string classKey)
IResourceProvider CreateLocalResourceProvider(string virtualPath)
...then implement your own IResourceProvider that gets your resources from your satellite assemblies using a ResourceManager
public interface IResourceProvider
{
object GetObject(string resourceKey, CultureInfo culture);
IResourceReader ResourceReader { get; }
}
You then need to add configuration to your web.config file to let ASP.NET know to use your SatelliteResourceProviderFactory and move your resources in to your external assemby, but that should be you good to go.
Plenty of documentation can be found here...under the "Building a Database Resource Provider" section...
http://msdn.microsoft.com/en-us/library/aa905797.aspx#exaspnet20rpm_topic4
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With