IMG-LOGO

Multiple Languages Support and Localization in DNN

andy - 14 Apr, 2016 8599 Views 4 Comment

DNN has a built in Localization framework to help you create website with multiple languages support. By default, the common HTML module shipped in DNN installation does support this feature. Unfortunately, not all of the third party modules available would be able to support multiple languages. If they do, usually they only support the languages via resx files. Those files are used to translate label text only, while the content is usually saved into the database directly.

How to setup multiple languages in DNN?

The default language in DNN is EN-US (USA Language version), if you want to add a new language, you will need to login as host super account and go to Admin > Languages Menu.

To add a new language, click the Add New Language button.

A pop up window will appear and you can select the available languages. Please select the English Name, so you can easily read the language selection combo text. The DNN team should make this option as default rather than the native name, as it is hard to guess the text.

Once you have add the new language, you will notice that there are two new flags available on the DNN skin. Notes: as we are using the default DNN skin, those flags will be automatically displayed. If you create your own skin or purchase it from third party vendors, you want may to manually add it on the skin. Here is the sample on how to do it. What you need to do is to include the DNN skin object at the top of your skin.ascx file.

//include this skin object tag
<%@ Register TagPrefix="dnn" TagName="LANGUAGE" Src="~/Admin/Skins/Language.ascx" %>

//Once you have add the skin object tag, you can now include the language tag to any location of your skin html.
<dnn:LANGUAGE runat="server" id="LANGUAGE1"  showMenu="False" showLinks="True" />

As you can see from above image, we do have two different languages supported on the site. The English language will still be the default language on the site. If you do want to change, the second language option become the default site language, you will need to go to Admin > Languages menu and click the Settings tab. Then select your preferred language as the default site language.

How localization work in DNN?

The way how localization works in DNN is by using the resx files. Those files are placed under App_LocalResources folder. The easy way to edit or add localization is by using Visual Studio program. If you do not have one, you can download the community version to do this. The simple example you can see on how localization has been applied in DNN is by looking on the DesktopModules folders. Let see the example of HTML module. All the resources files are identical with the module ascx files name.

DNN has a built in resource label skin object, you can use this one to display the localization text. There is a tag called ID in this skin object which represents the ID of the resource label. The way how it works is, the DNN will look for the ID value, in this example, the value is lblResourceText, DNN will search if there is resource record defined in the resx file named lblResourceText, if it does find the record, it will use the defined value specified in the file otherwise it will use the default value tag specified in the Label object which contains the value Resource Text.

//this is the skin label object
<%@ Register TagPrefix="dnn" TagName="Label" Src="~/controls/LabelControl.ascx" %>

//an example on how to use the label text.
<dnn:Label id="lblResourceText" runat="server" Text="Resource Text" />

If you are a programmer, you can set the localization via behind code by using the following code. The LocalResourceFile represents the resource file name. For example: if your control name is MyControl.ascx then the resource file name will be MyControl.ascx.resx

Localization.GetString("ResourceTextName", LocalResourceFile);

Comments

JER
21 Jul, 2016
Great article. What I don't understand is how to make the page actually display the second language. I have a fresh install of DNN8. My home page is the default for a fresh American English install. I chose Polski as my second language. I have the flag in the navbar. Nothing happens to my page when I click the polish flag. All the text on the home page is still displayed in English.
RDK
23 Jan, 2019
It is because the fallback language is English. So if you have not entered any value for the content in Polski, it will automatically display content from English.
Parov
13 Jan, 2017
To better organize the localization workflow, I think would be a good idea to use an online localization platform like https://poeditor.com Localizing strings in collaboration with the whole l10n team, using the same translation interface, should significantly improve productivity.
Rebecca Harris
21 Mar, 2022
I'm pretty sure you misspelled the word "didnt" on your site. You might want to check out a site like SpellRadar.com or SiteCheck.com which have helped me with problems like this in the past.
Write Comment
0 characters entered. Maximum characters allowed are 1000 characters.

Related Blogs

How to change copyright text in DNN?

In this article, I am going to show you how to change the copyright text in DNN. Usually, a copyright text is located under the footer of the site template.

Related Tutorials

Create your first DNN module extension

In this tutorial you will learn how to create your first DNN module This will be a basic module that will display Hello World You will learn also how to get a module setting and save the value into module ...

How to Install DotNetNuke?

This tutorial would be a good start for DNN newbie I have attached screenshots to help you on how to install the DotNetNuke step by step You can try this in your local computer first before installing it on live ...

What is DNN?

DNN is an open source web content management system based on Microsoft Net It was written in VB Net but it has been fully migrated to C since version 6 0 There are three versions available for DNN which are ...

How to install module extension in DotNetNuke?

What is actually a module extension in DNN A module extension can be considered as plugin program that you can install on your site Just imagine you have a car and you want to add a new sound system to ...

How to create a simple skin in DNN?

Learn how to create your first new skin template in DNN. You will also learn what are required to create the DNN skin template and what is the structure of the template looks like.