Back to Devexpress

XtraLocalizer<T>.GetLocalizedString(T) Method

corelibraries-devexpress-dot-utils-dot-localization-dot-xtralocalizer-1-dot-getlocalizedstring-x28-0-x29.md

latest3.8 KB
Original Source

XtraLocalizer<T>.GetLocalizedString(T) Method

Gets the string, localized by the current XtraLocalizer<T>, for the specified user interface element.

Namespace : DevExpress.Utils.Localization

Assembly : DevExpress.Data.v25.2.dll

NuGet Package : DevExpress.Data

Declaration

csharp
public virtual string GetLocalizedString(
    T id
)
vb
Public Overridable Function GetLocalizedString(
    id As T
) As String

Parameters

NameTypeDescription
idT

A T enumeration value specifying the UI element whose caption (text) is to be localized.

|

Returns

TypeDescription
String

A String representing the text to be displayed within the specified UI element.

|

Remarks

This method should be overridden a XtraLocalizer<T> class’ descendants, in order to modify the captions (text strings) of visual user interface elements. The GetLocalizedString method gets a string ID (represented by an appropriate enumeration value) and should return an appropriate string.

Example

The code below demonstrates how you can localize Vertical Grid‘s captions in the row header context menu.

csharp
using DevExpress.XtraVerticalGrid.Localization;

VGridLocalizer.Active = new MyVGridLocalizer();

class MyVGridLocalizer : VGridLocalizer {
    public override string Language { get { return "English"; } }
    public override string GetLocalizedString(VGridStringId id) {
        switch (id) {
            case VGridStringId.MenuPropertySortAscending: return "Sort Ascending";
            case VGridStringId.MenuPropertySortDescending: return "Sort Descending";
            case VGridStringId.MenuPropertyClearSorting: return "Clear Sorting";
            case VGridStringId.MenuPropertyClearSortingAllProperties: return "Clear All Sorting";
            default: return base.GetLocalizedString(id);
        }
    }
}
vb
Imports DevExpress.XtraVerticalGrid.Localization

VGridLocalizer.Active = New MyVGridLocalizer()

Friend Class MyVGridLocalizer
    Inherits VGridLocalizer

    Public Overrides ReadOnly Property Language As String
        Get
            Return "English"
        End Get
    End Property

    Public Overrides Function GetLocalizedString(ByVal id As VGridStringId) As String
        Select Case id
            Case VGridStringId.MenuPropertySortAscending
                Return "Sort Ascending"
            Case VGridStringId.MenuPropertySortDescending
                Return "Sort Descending"
            Case VGridStringId.MenuPropertyClearSorting
                Return "Clear Sorting"
            Case VGridStringId.MenuPropertyClearSortingAllProperties
                Return "Clear All Sorting"
            Case Else
                Return MyBase.GetLocalizedString(id)
        End Select
    End Function
End Class

See Also

XtraLocalizer<T> Class

XtraLocalizer<T> Members

DevExpress.Utils.Localization Namespace