Localization: Easily translate your DotNetNukeŽ module (in VB and C#)

An advantage to using the DotNetNuke framework is it's extensive support for Localization. This provides the ability to translate the content of a portal. The key to making this work, is that the module programmer must allow the module to be Localized.

What Localization Will Do For You

A typical scenario shows the steps a portal administrator would make to provide a Spanish translation for users of their portal.

1. The Portal administrator logs in as the Host account and adds a Locale from the Host -> Languages menu

2. The Portal administrator uses the Language Editor and selects the User Control to be localized and chooses the Locale.

3. The administrator then enters translations in the file:

4. The Visitors to the Portal can select Manage Profile

5. And change their Preferred Locale

6. And the module will display in the chosen language.

Implementing Localization for the Survey Module

Localizing Static Content

In the Survey module, we ensured that various text elements were Localized by using labels rather than text. All other controls such as link buttons are easily localized. Link buttons such as this:

Are coded with a unique resourcekey.

<asp:linkbutton id="cmdSubmit" runat="server" resourcekey="cmdSubmit" cssclass="CommandButton">Submit Survey</asp:linkbutton>
asp:linkbutton id="cmdResults" runat="server" resourcekey="cmdResults" cssclass="CommandButton">View Results</asp:linkbutton>

The User Control...

Is accompanied by resource files that begin with the same name and reside in the App_LocalResouces directory (that resides in the module folder).

The resource file contains the resource key and the value that will be displayed.

Localizing Dynamic Content

For the text that is generated dynamically such as the Administrator menu...

The same resource file is used.

This code is used to return the localized value:

Localization.GetString(Entities.Modules.Actions.ModuleActionType.AddContent, LocalResourceFile)

How to Localize Your modules

Open your module in Visual Studio in Design mode.

(note that only controls can be localized so you will want to use a control for all text. For example, use a label control for all text.)

From the Toolbar select Tools then Generate Local Resource

(Generate Local Resource is only available if using C#. If using Visual Basic you must create the file manually)

A resource file will be created.

It will be placed in a App_LocalResources folder

It will also place "meta:" in front of each resource tag

Remove "meta:" from each tag and save the page.

Localize the resource files following the previous directions. After you localize the page, re-build the page in Visual Studio.

You can download the VB Version of the Survey Module for full examples of localization.

[Back to: The ADefWebserver DotNetNuke HELP WebSite]

DotNetNukeŽ is a registered trademark of Perpetual Motion Interactive Systems Inc.