The main configuration for DbResourceProvider is handled through web.config and the special DbResource Provider section.

<configuration> <configSections> <section name="DbResourceProvider" type="Westwind.Globalization.DbResourceProviderSection" requirePermission="false"/> </configSections> <DbResourceProvider connectionString="MyAppplicationConnectionString" resourceTableName="Localizations_Padnug" projectType="WebForms" designTimeVirtualPath="/internationalization" showLocalizationControlOptions="true" showControlIcons="true" localizationFormWebPath="~/localizationadmin/localizationAdmin.aspx" addMissingResources="false" useVsNetResourceNaming="false" stronglyTypedGlobalResource="~/_Classes/Resources.cs,AppResources" /> </configuration>

You need to add a new Config Section header in the configSections area and then actually provide the configuration section.

In addition you need to also enable the provider in the globalization section:

<system.web> <globalization resourceProviderFactoryType="Westwind.Globalization.DbSimpleResourceProviderFactory,Westwind.Globalization" /> <!-- <globalization resourceProviderFactoryType="Westwind.Globalization.DbResourceProviderFactory,Westwind.Globalization" /> -->Ý </system.web>

Important
Do not enable the database Resource Provider until you have created the resource table and imported resources from any .Resx files you may have used for localization while running with the stock Resx provider. If you don't do this all your resources will render blank for any localized content including the resource administration form.

To start run the Admin LocalizeForm.aspx. If the resource table doesn't exist, create it by using the Create Table button. Once the table exists go ahead and import the .Resx resources. Once you have resource data in the admin UI you know the provider is properly configured and you can go ahead and enable the provider.

Two Providers

Note that this library ships with two providers, DbResourceProvider and DbSimpleResourceProvider. The full DbResourceProvider implements both a ResourceProvider and ResourceManager so it can be used both in Web, Windows and library projects. DbSimpleResourceProvider is an ASP.NET only implementation that foregoes the ResourceManager implementation and directly accesses the data components which results in a better performing interface (roughly 1.5-2% faster). Both providers behave identically and use the underlying data and configuration interfaces but the resource manager interfaces uses both the ResourceProvider interface as well as the ResourceManager interface to feed that data which creates the extra overhead.

DbResourceProvider Configuration Settings

The resource provider is configured via the DbResourceProvider configuration settings in the application config file (web.config or app.config). These settings are used both at runtime and at design time so it's important that this section is set up appropriately as soon as you enable the resource provider.

Most of the settings are fairly self explanatory and you can review them in detail in the DbResourceConfiguration class docs.

connectionString
This is the most important key that determines the name of a SQL Server database that the data is stored in. This string can be a full connection string or a key from the .Config ConnectionStrings section.

Once provided the provider tries to create the database table in the resourceTableName key in the database. The connection string should have rights to create the table. If rights are not available you can manually create the table in the database as described in the Creating the Database topic.

resourceTableName
The name of the resource table. The default is Localizations.

projectType
The administration interface supports two types of projects for importing and exporting resources from: The two values supported are:

  • WebForms
  • Class

The WebForms format involves reading local and global resources out of App_GlobalResources/App_LocalResource folders. The Class format is used for everything else including MVC projects.

designTimeVirtualPath
This is the virtual path of your Web Application as seen by Visual Studio. This path is used for the Generate Local Resources option in the Visual Studio Web Form designer. The path is used to strip off the virtual path for each page. Make sure you get the virtual path correct or your resource names will get screwed up. If you see full paths that start with a / for ResourceSet names you know your virtual path is incorrect. Default is: ~/localizationAdmin/localizationAdmin.aspx.

showLocalizationControlOptions
Determines whether the DbDataResourceControl shows on pages that it's been placed on. This option is basically a global switch that enables this control. When the switch is set to true, the control shows if it exists, otherwise it never does anywhere on the site. This is useful in order to switch the site in and out of Resource editing mode without having to add and remove the control.

showControlIcons
Determines whether a page that shows the above control shows icons for each of the localizable resources on the page. Note that icons are shown only next to controls that are marked as [Localizable] (either by your own controls or by stock ASP.NET controls). Some localizable properties (like GridView Columns for example) won't show up however, because they are not controls although they may be marked as implict resources.

localizationFormWebPath
This is the path to the LocalizeForm.aspx that is shipped with the provider. This form provides the interactive Web interface for Resource Localization and you must copy this page into your Web application (preferrably into a separate directory) and then provide a path to it. The DbResourceControl uses this URL to find the administration form and bring it up for resource editing.

addMissingResources
If true adds any missing resources into the database automatically as empty entries for the invariant language.

useVsNetResourceNaming
If true uses Implicit Resource naming the way Visual Studio does which includes a ResourceX postfix to each assigned control. The default for this provider is to use the control name as the resource key if possible and only add a counter if there's duplication, which makes for much more readable resource names.

stronglyTypedGlobalResource
When this value is not blank exporting resources to .ResX files causes a strongly typed resource file to be created. This file properly works with ASP.NET's GetLocal/GlobalResourceObject rather than the stock resources created by Visual Studio (which is very ineffcient). You can also separately generate these resources with GenerateStronglyTypedResources.aspx page in the admin folder. The value is specified as a virtual path to the source file (use .cs or .vb to identify language) and a namespace to generate (for example: ~/Classes/Resources.cs, AppResources).

Optional ScriptCompression Module and JavaScriptResource Handler

We also recommend you install the Westwind.Web.ScriptCompression module which minimized and GZip compresses resources and the JavaScriptResourceHandler which provides client side with localized server resources on the client.

IIS 7:

<configuration> <system.webServer> <validation validateIntegratedModeConfiguration="false"/> <modules> <add name="ScriptCompressionModule" type="Westwind.Web.ScriptCompressionModule,Westwind.Web"/> </modules> <handlers> <add name="JavaScriptResourceHandler" verb="GET" path="JavascriptResourceHandler.axd" type="Westwind.Globalization.JavaScriptResourceHandler,Westwind.Globalization"/> </handlers> </system.webServer> </configuration>

IIS 6/5/5.5:

<configuration> <httpModules> <add name="ScriptCompressionModule" type="Westwind.Web.ScriptCompressionModule,Westwind.Web"/> </httpModules> <httpHandlers> <add verb="GET" path="JavaScriptResourceHandler.axd" type="Westwind.Globalization.JavaScriptResourceHandler,Westwind.Globalization"/> </httpHandlers> </system.web> </configuration>