Products

Solutions

Resources

Partners

Community

About

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

  • 4/7/2015
  • 2449 Views

Comments

2449 Views

ILocalizable

Last updated long time ago

Comments

Common

(Enter the content of this article below)

Advanced

 
The ILocalizable interface which is part of the DotNetNuke.Web project was first introduced in DotNetNuke framework version 05.03.00. It's members consist of two properties and one method:

Namespace DotNetNuke.Web.UI

Public Interface ILocalizable
Property LocalResourceFile() As String
Property Localize() As Boolean
Sub LocalizeStrings()
End Interface
End Namespace

So far, ILocalizable is only being implemented in several of the custom server controls also defined in the DotNetNuke.Web project. For example, here is the implementation in DotNetNuke.Web.UI.WebControls.DnnLabel:

#Region "Private Members"

Private _Localize As Boolean = True
Private _LocalResourceFile As String
#End Region

#Region "ILocalizable Implementation"
Public Property Localize() As Boolean Implements ILocalizable.Localize
Get
If (DesignMode) Then
Return False
End If
Return _Localize
End Get
Set(ByVal value As Boolean)
_Localize = value
End Set
End Property

Public Property LocalResourceFile() As String Implements ILocalizable.LocalResourceFile
Get
Return _LocalResourceFile
End Get
Set(ByVal value As String)
_LocalResourceFile = value
End Set
End Property

Protected Overridable Sub LocalizeStrings() Implements ILocalizable.LocalizeStrings
If (Localize) Then
If (Not String.IsNullOrEmpty(ToolTip)) Then
ToolTip = Localization.GetString(ToolTip, LocalResourceFile)
End If

If (Not String.IsNullOrEmpty(Text)) Then
Text = Localization.GetString(Text, LocalResourceFile)

If (String.IsNullOrEmpty(ToolTip)) Then
ToolTip = Localization.GetString(String.Format("{0}.ToolTip", Text), LocalResourceFile)
End If
End If
End If
End Sub
#End Region

In the control's override of the Render method, LocalizeStrings is called to localize the label's Text and Tooltip properties with localization values being retrieved from the LocalResourceFile that was specified during the control's override of the PreRender method:

#Region "Protected Methods"

Protected Overrides Sub OnPreRender(ByVal e As System.EventArgs)
MyBase.OnPreRender(e)
LocalResourceFile = Utilities.GetLocalResourceFile(Me)
End Sub

Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)
LocalizeStrings()
MyBase.Render(writer)
End Sub
#End Region

The method GetResourcesFile(ByVal ctrl As Control) As String is defined in the DotNetNuke.Web.UI.Utilities namespace. It returns the full path to the control's local resource file (.resx) or to that of the nearest parent control if the control does not specify it's own local resource file.

I am not sure is the ILocalizable interface will be implemented outside of the DotNetNuke.Web project but suspect that with time it's importance will increase.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out