New to Telerik UI for WinForms? Download free 30-day trial

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);
        }
    }
}

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


DiagramRibbonBarLocalizationProvider.CurrentProvider = new MyDiagramRibbonBarLocalizationProvider();

WinForms RadDiagram Localization Provider

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);
        }
    }
}

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


DiagramSettingsPaneLocalizationProvider.CurrentProvider = new MyDiagramSettingsPaneLocalizationProvider();

WinForms RadDiagram Custom Localization Provider