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 adds a Locale from the Admin -> 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)

You can download C# Version of the Survey Module and 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.