Module Localization in DNN

依然范特西╮ 提交于 2019-12-05 09:13:20
karbonphyber

Localization of a module is pretty easy thanks to DotNetNuke.

Wherever your .ascx (View) file is, the App_LocalResources folder should always accompany it, on the same level. There should also be a corresponding .ascx.resx file in that folder.

view.ascx
App_LocalResources
- view.ascx.resx

Once you have that structure in your module. DNN will pick the file up immediately.

To use that resource strings in the resx. Simple tack on the ResourceKey property to the end of your asp controls. e.g.

<asp:Label ID="lblExample" runat="server" ResourceKey="lblExample" />

You should have a lblExample.Text in your resx file which matches up with that label. Note that it adds .Text to it automatically.

If it's not showing up, there are a few things to check

  1. LocalResourceFile property in code. What location is it pointing to?
  2. set ShowMissingKeys=true in web.config and you'll see what resource strings you're missing.

Please find this document. I am not sure if it covers your questions and how localizing DotNetNuke modules is different from other Asp.Net applications but please try it out.
If I may suggest something, I would add more tags in the future (like C# for example), it will be visible to broader audience which may result in better answers.

Simply create a folder called "App_LocalResources" on the same level as your .ascx view files in your project. For each file that you want localized, simply add a .resx file with the same name as the view (including the .ascx extension).

Resx Name Example:

"View.ascx.resx"

Using localistion is really easy after that. Simply set the Resource Key property of whichever controls you want to pull from your resx file to a meaningful name

Example:

<dnn:Label id="lblName" ResourceKey="lblName" runat="server" />

Resx File:

"lblName.Text" will assign to the Text property of the label "lblName.Help" will assign to the DNN Tooltip property if you are using dnn:Labels like above

If you want to start using DNN Labels simply put this tag at the top of your page.

<%@ Register TagPrefix="dnn" Assembly="DotNetNuke.Web" Namespace="DotNetNuke.Web.UI.WebControls" %>
<%@ Register TagPrefix="dnn" TagName="Label" Src="~/controls/LabelControl.ascx" %>

Another handy method available is:

LocalizeString("key")

It will pull from your resource file and it quite handy when working with things like email templates.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!