DNN Platform ASP.NET Localization BuildProvider
Learn more about this project, including background and history, on
This project enables full use of ASP.NET localization functionality (including strongly-typed access and meta:resourcekey support) in a DotNetNuke application.*
This BuildProvider is able to consume version 2.0 and 1.3 ResX resource files, and tolerates resource files that are missing valid resheader metadata (both DotNetNuke core releases and external language packs commonly omit this information).
Because the base System.Web.Compilation.BuildProvider has an InheritanceDemand (and System.Resources.ResXResourceReader has a LinkDemand) requiring full trust, this project is only operational on installations with this level of authorization.
- Require no core changes
- Be side-by-side compatible with the existing DotNetNuke localization services
- Require little configuration by a hosting user
- Allow strongly-typed per-portal and per-culture access to existing global DotNetNuke resources
- Minimal additional in-memory footprint and reasonable performance
- Enable use of the meta:resourcekey attribute in DotNetNuke modules
- Be fully compatibility with third-party modules
This project includes a custom BuildProvider which handles the full compilation life cycle for ResX files within a DotNetNuke application; in this manner such files may continue to exist in the App_GlobalResources directory and be fully side-by-side compatible
with the DotNetNuke localization system. Further, deployment enables portal-specific resource customizations to extend to the ResourceManager (including both strongly- and weakly-typed access).
For example, the strongly-typed variable (enabled via this BuildProvider) Resources.GlobalResources.ErrorText will consistently yield the same value obtained through a DotNetNuke.Services.Localization.Localization.GetString(”Error”, Localization.GlobalResourceFile)
customized for the current portal_.
Similarly, a meta:resourcekey attribute on an appropriately named control will yield the same value obtained through a call to UserModuleBase.GetLocalResourceObject(…).
1. Strongly-Typed Access
Access localized, portal-specific
DotNetNuke global resources in a strongly typed manner, e.g.:
2. ResourceManager Access
Access cached ResourceManager objects for ad-hoc resource access:
3. Meta:ResourceKey attributes
Access local resources using the traditional ASP.NET 2.0 meta:resourcekey attribute:
- <asp:Label runat="server" meta:resourcekey="MyResource" />
Configuration is straightforward, requiring only a single additional node in the web.config file
<remove extension=".resx" />
<remove extension=".resources" />
Here, we keep the existing DotNetNuke <remove> elements and add the new BuildProvider to the list. During startup, ASP.NET will utilize this BuildProvider to compile all files with the .ResX extension. This BuildProvider will handle strongly-typed class
generation, ResourceManager decoration, and enable full ASP.NET localization within the application. That’s it!
Your feedback is greatly appreciated!
As I work to confirm that this BuildProvider works properly across a wider variety of installations, I would appreciate any and all feedback about the experiences of those using it. It is greatly appreciated. If it works for you, please let me know!
* This BuildProvider has been tested against DotNetNuke version 4.9 and 5.0RC1.
** Manual web.config modification is required only under DotNetNuke 4.x versions; an anticipated 5.0 package (not yet released) is expected to automatically make the necessary change.