Localization in Windows Forms Docking Manager
27 Apr 20214 minutes to read
Localization is the process of translating the application resources into different languages for specific cultures. DockingManager
supports complete localization to any desired language of header and context menus of docking child windows. It can be localized by using ILocalizationProvider.
The following steps help to localize the header and context menus of docking child windows in the docking manager:
Step 1: Include the required namespaces at the beginning of the file.
using Syncfusion.Windows.Forms;
using Syncfusion.Windows.Forms.Tools;
Imports Syncfusion.Windows.Forms
Imports Syncfusion.Windows.Forms.Tools
Step 2: Initialize the LocalizationProvider class inherited from the ILocalizationProvider interface before the InitializeComponent is called in the constructor of an application.
LocalizationProvider.Provider = new Localizer();
LocalizationProvider.Provider = New Localizer()
Step 3: Add the GetLocalizedString function in the LocalizationProvider class in which the localization content is provided for required components that are used in the docking manager.
For example: Header and ContextMenu of docking child windows are localized in Chinese Language.
Localize header of child window
SetDockLabel helps to localize the label for a child window.
// To set the label for the docked controls
this.dockingManager.SetDockLabel(panel1, "解 探险者");
this.dockingManager.SetDockLabel(panel2, "工具箱");
this.dockingManager.SetDockLabel(panel3, "属性");
this.dockingManager.SetDockLabel(panel4, "产量");
' To set the label for the docked controls
Me.dockingManager.SetDockLabel(panel1, "解 探险者");
Me.dockingManager.SetDockLabel(panel2, "工具箱");
Me.dockingManager.SetDockLabel(panel3, "属性");
Me.dockingManager.SetDockLabel(panel4, "产量");
Localize ContextMenu options
The following code example illustrates how to localize the context menus of docking child windows in the docking manager.
public string GetLocalizedString(System.Globalization.CultureInfo culture, string name,object obj)
{
switch (name)
{
case ToolsResourceIdentifiers.DockableMenuItemText:
return "可停靠";
case ToolsResourceIdentifiers.AutoHideMenuItemText:
return "自动隐藏";
case ToolsResourceIdentifiers.FloatingMenuItemText:
return "漂浮的";
case ToolsResourceIdentifiers.MDIChildMenuItemText:
return "MDI 子";
case ToolsResourceIdentifiers.HideMenuItemText:
return "隐藏";
case ToolsResourceIdentifiers.MenuItemDockToLeft:
return "剩下";
case ToolsResourceIdentifiers.MenuItemDockToRight:
return "对";
case ToolsResourceIdentifiers.MenuItemDockToTop:
return "最佳";
case ToolsResourceIdentifiers.MenuItemDockToBottom:
return "底部";
case ToolsResourceIdentifiers.MenuItemDockTo:
return "码头";
default:
return string.Empty;
}
}
Public Function GetLocalizedString(ByVal culture AsSystem.Globalization.CultureInfo, ByVal name As String, ByVal obj As Object) AsString
Select Case name
Case ToolsResourceIdentifiers.DockableMenuItemText:
Return "可停靠";
Case ToolsResourceIdentifiers.AutoHideMenuItemText:
Return "自动隐藏";
Case ToolsResourceIdentifiers.FloatingMenuItemText:
Return "漂浮的";
Case ToolsResourceIdentifiers.MDIChildMenuItemText:
Return "MDI 子";
Case ToolsResourceIdentifiers.HideMenuItemText:
Return "隐藏";
Case ToolsResourceIdentifiers.MenuItemDockToLeft:
Return "剩下";
Case ToolsResourceIdentifiers.MenuItemDockToRight:
Return "对";
Case ToolsResourceIdentifiers.MenuItemDockToTop:
Return "最佳";
Case ToolsResourceIdentifiers.MenuItemDockToBottom:
Return "底部";
Case ToolsResourceIdentifiers.MenuItemDockTo:
Return "码头";
Case Else
Return String.Empty
End Select
End Function
NOTE
Refer to the following sample link that demonstrates the localization support in the docking manager.
C:\Users\<User>\AppData\Local\Syncfusion\Essential Studio\Version Number\Windows\Tools.Windows\Samples\Docking manager\Localization