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