Edit this page

Localization

This tutorial describes the localization support implemented in RadDiagram.

Localizing RadDiagramRibbonBar

To localize RadDiagramRibbonBar to display control text and messages in a specific language:

1. Start by creating a descendant of the DiagramRibbonBarLocalizationProvider class.

2. Override the GetLocalizedString(string id) method and provide a translation for the texts. If a translation is not provided, the default value will be returned. This behavior is guaranteed by the call to the base GetLocalizedString method in the default clause of the switch statement in the example. Below is a sample implementation of a custom localization provider:


public class MyDiagramRibbonBarLocalizationProvider : DiagramRibbonBarLocalizationProvider
{
    public override string GetLocalizedString(string id)
    {
        switch (id)
        {
            case DiagramRibbonBarStringId.DiagramRibbonBarHomeTab:
                return "MyHome";
            case DiagramRibbonBarStringId.DiagramRibbonBarButtonOpen:
                return "MyOpen";
            default:
                return base.GetLocalizedString(id);
        }
    }
}

Public Class MyDiagramRibbonBarLocalizationProvider
    Inherits DiagramRibbonBarLocalizationProvider
    Public Overrides Function GetLocalizedString(id As String) As String
        Select Case id
            Case DiagramRibbonBarStringId.DiagramRibbonBarHomeTab
                Return "MyHome"
            Case DiagramRibbonBarStringId.DiagramRibbonBarButtonOpen
                Return "MyOpen"
            Case Else
                Return MyBase.GetLocalizedString(id)
        End Select
    End Function
End Class

3. To apply the custom localization provider, instantiate and assign it to the current localization provider:


DiagramRibbonBarLocalizationProvider.CurrentProvider = new MyDiagramRibbonBarLocalizationProvider();

DiagramRibbonBarLocalizationProvider.CurrentProvider = New MyDiagramRibbonBarLocalizationProvider()

diagram-localization 001

Localizing SettingsPane

To localize RadDiagramSettingsPane to display control text and messages in a specific language:

1. Start by creating a descendant of the DiagramSettingsPaneLocalizationProvider class.

2. Override the GetLocalizedString(string id) method and provide a translation for the texts. If a translation is not provided, the default value will be returned. This behavior is guaranteed by the call to the base GetLocalizedString method in the default clause of the switch statement in the example.


public class MyDiagramSettingsPaneLocalizationProvider : DiagramSettingsPaneLocalizationProvider
{
    public override string GetLocalizedString(string id)
    {
        switch (id)
        {
            case DiagramSettingsPaneStringId.LabelCopy:
                return "MyCopy";
            case DiagramSettingsPaneStringId.LabelPaste:
                return "MyPaste";
            case DiagramSettingsPaneStringId.LabelCut:
                return "MyCut";
            case DiagramSettingsPaneStringId.LabelDelete:
                return "MyDelete";
            default:
                return base.GetLocalizedString(id);
        }
    }
}

Public Class MyDiagramSettingsPaneLocalizationProvider
    Inherits DiagramSettingsPaneLocalizationProvider
    Public Overrides Function GetLocalizedString(id As String) As String
        Select Case id
            Case DiagramSettingsPaneStringId.LabelCopy
                Return "MyCopy"
            Case DiagramSettingsPaneStringId.LabelPaste
                Return "MyPaste"
            Case DiagramSettingsPaneStringId.LabelCut
                Return "MyCut"
            Case DiagramSettingsPaneStringId.LabelDelete
                Return "MyDelete"
            Case Else
                Return MyBase.GetLocalizedString(id)
        End Select
    End Function
End Class

3. To apply the custom localization provider, instantiate and assign it to the current localization provider:


DiagramSettingsPaneLocalizationProvider.CurrentProvider = new MyDiagramSettingsPaneLocalizationProvider();

DiagramSettingsPaneLocalizationProvider.CurrentProvider = New MyDiagramSettingsPaneLocalizationProvider()

diagram-localization 002