Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • Localization of a module in DotNetNuke

    • 0
    • 2
    • 2
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.31k
    Comment on it


    While creating a website to reach more and more people irrespective of their language, it becomes the need of the time to make the website a multi-lingual application. DNN achieves localization through the use of resource files. Resource files are files with extensions .resx which supply the name value pairs used for text replacement within the module. As in DNN we have different modules to achieve different functionalities, we can make those modules multi-lingual using the following method.

    Generally in DNN the modules are located under the folder named "DesktopModules" having the path something like "testWebsite/DesktopModules" where "testWebsite" is the name of the folder containing all files. Now suppose we have created our module called "testModule" with a user control file named as "View.ascx" in which we want to apply localization then our "testModule" will be placed under "DesktopModules" having location as "testWebsite/DesktopModules/testModule".

    Now to apply the localization to this module we must have a directory named as "App_LocalResources" inside module folder we just created. There should also be a corresponding .ascx.resx file in "App_LocalResources". In addition the resource file must share the name of the user-control which is View.ascx in our case. For example, the user-control having path as"myWebsite/DesktopModules/myModule/View.ascx" would have the resource file "testWebsite/DesktopModules/testModule/App_LocalResources/View.ascx.resx".

    Hierarchy is as shown below:

       --> DesktopModules
             ---> testModule
                     ---> View.ascx
                     ---> App_LocalResources
             ---> View.ascx.resx

    How to use the resource file. When all the rules are properly taken care of then we will be able to reference the resource file through the LocalResourceFile property. In DotNetNuke we have two ways of localizing text with the help of resource file.

    Note: In the below example we are having the Name value as ""lblDisplay.Text" and Value value as "Display Localization".

    Two methods are as follows:

    First method is to set the ResourceKey attribute of the server control in user control's html. for eg.

    <asp:Label ID="lblDisplayValue" runat="server" ResourceKey="lblDisplay.Text" />

    Second method is to set the server control's Text property in the user control's code behind. for eg.

    lblDisplayValue.Text = Localization.GetString("lblDisplay.Text", LocalResourceFile)

 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: