Localization Support in Windows Forms Ribbon (RibbonControlAdv)
10 Oct 202220 minutes to read
RibbonControlAdv now supports adaptation of its controls and its details to meet different languages and cultural requirements. This involves configuring the ribbon to a specific language.
Adding ILocalizationProvider
-
Include the required namespaces at the beginning of the source file.
-
Create a class that implements the
ILocalizationProvider
interface defined in the Syncfusion.Windows.Forms namespace in the Syncfusion.Shared.Base.dll. -
Return the localized versions of the strings corresponding to the string identifiers.
-
String identifiers are defined in the
ToolsResourceIdentifier
classes in Syncfusion.Tools.Windows
using Syncfusion.Windows.Forms.Tools;
Imports Syncfusion.Windows.Forms.Tools
-
Leave an empty string for the rest of the identifiers that are not involved in the localization. These identifiers are loaded with a default value.
-
Assign this instance to the Provider property of the LocalizationProvider class before the InitializeComponent call in the constructor of the application.
LocalizationProvider.Provider = new localization();
LocalizationProvider.Provider = New localization()
- The Following is an example for localization
class localization : ILocalizationProvider
{
public string GetLocalizedString(System.Globalization.CultureInfo culture, string stringname, object obj)
{
switch (stringname)
{
case ToolsResourceIdentifiers.CustomizeRibbonDialogButtonAdd:
return "啊錒别 ";
case ToolsResourceIdentifiers.CustomizeRibbonDialogButtonRemove:
return "可用呢 ";
case ToolsResourceIdentifiers.CustomizeRibbonDialogButtonCancel:
return "锕如如 ";
case ToolsResourceIdentifiers.CustomizeRibbonDialogButtonOk:
return "别";
case ToolsResourceIdentifiers.CustomizeRibbonDialogButtonReset:
return "地方把小";
case ToolsResourceIdentifiers.CustomizeRibbonDialogLabel:
return "都非";
case ToolsResourceIdentifiers.CustomizeRibbonDialogChooseCommands:
return "无后们 ";
case ToolsResourceIdentifiers.CustomizeRibbonDialogMainTab:
return "无拍 ";
case ToolsResourceIdentifiers.CustomizeRibbonDialogButtonNewGroup:
return "才了 ";
case ToolsResourceIdentifiers.CustomizeRibbonDialogButtonNewTab:
return "来把 ";
case ToolsResourceIdentifiers.CustomizeRibbonDialogButtonRename:
return "人额女";
case ToolsResourceIdentifiers.CustomizeRibbonDialogCustomizationLabel:
return "才上 来锕把";
case ToolsResourceIdentifiers.CustomizeRibbonDialogCaption:
return "才上 人额女";
case ToolsResourceIdentifiers.CustomizeQuickAccessLabel:
return "才上 来锕把";
case ToolsResourceIdentifiers.QuickAccessCustomizeMenu:
return "啊錒别";
case ToolsResourceIdentifiers.QuickAccessAddItem:
return "啊錒别";
case ToolsResourceIdentifiers.QuickAccessDialogButtonAdd:
return "啊錒别";
case ToolsResourceIdentifiers.QuickAccessDialogButtonCancel:
return "锕如如";
case ToolsResourceIdentifiers.QuickAccessDialogButtonOk:
return "别";
case ToolsResourceIdentifiers.QuickAccessDialogButtonReset:
return "地方把小";
case ToolsResourceIdentifiers.QuickAccessDialogButtonRemove:
return "可用呢";
case ToolsResourceIdentifiers.QuickAccessMinimizeTheRibbon:
return "啊錒别 如额呢";
case ToolsResourceIdentifiers.QuickAccessPlaceAboveRibbon:
return "錒为你 啊錒别 ";
case ToolsResourceIdentifiers.QuickAccessPlaceBelowRibbon:
return "地方把小 无不的 ";
case ToolsResourceIdentifiers.QuickAccessToolBarLabel:
return "地方把小 无不的 ";
case ToolsResourceIdentifiers.CustomizeRibbonDialogRenameCancelButton:
return "锕如如";
case ToolsResourceIdentifiers.CustomizeRibbonDialogRenameCaption:
return "如额你啊吗额";
case ToolsResourceIdentifiers.CustomizeRibbonDialogRenameOkButton:
return "别";
case ToolsResourceIdentifiers.CustomizeRibbonRenameDisplayLabel:
return "都三片来啊 了阿不";
case ToolsResourceIdentifiers.CustomizationLabel:
return "都三片来啊 了阿不";
case ToolsResourceIdentifiers.CustomizeMenu:
return "都三片来啊 了阿不";
case ToolsResourceIdentifiers.QuickAccessDialogDropDownName:
return "都三片来啊 了阿不";
case ToolsResourceIdentifiers.QuickAccessCustomizeCaption:
return "都三片来啊 ";
case ToolsResourceIdentifiers.QuickAccessDialogCommands:
return "都三片来啊 ";
case ToolsResourceIdentifiers.CustomizeRibbonDialogColumnHeader:
return "都三片来啊 ";
case ToolsResourceIdentifiers.CustomMenu:
return "都三片来啊 ";
case ToolsResourceIdentifiers.QuickAccessDialogCustomizeRibbon:
return "都三片来啊 ";
default:
return string.Empty;
}
}
}
Class localization
Inherits ILocalizationProvider
Public Function GetLocalizedString(ByVal culture As System.Globalization.CultureInfo, ByVal stringname As String, ByVal obj As Object) As String
Select Case stringname
Case ToolsResourceIdentifiers.CustomizeRibbonDialogButtonAdd
Return "啊錒别 "
Case ToolsResourceIdentifiers.CustomizeRibbonDialogButtonRemove
Return "可用呢 "
Case ToolsResourceIdentifiers.CustomizeRibbonDialogButtonCancel
Return "锕如如 "
Case ToolsResourceIdentifiers.CustomizeRibbonDialogButtonOk
Return "别"
Case ToolsResourceIdentifiers.CustomizeRibbonDialogButtonReset
Return "地方把小"
Case ToolsResourceIdentifiers.CustomizeRibbonDialogLabel
Return "都非"
Case ToolsResourceIdentifiers.CustomizeRibbonDialogChooseCommands
Return "无后们 "
Case ToolsResourceIdentifiers.CustomizeRibbonDialogMainTab
Return "无拍 "
Case ToolsResourceIdentifiers.CustomizeRibbonDialogButtonNewGroup
Return "才了 "
Case ToolsResourceIdentifiers.CustomizeRibbonDialogButtonNewTab
Return "来把 "
Case ToolsResourceIdentifiers.CustomizeRibbonDialogButtonRename
Return "人额女"
Case ToolsResourceIdentifiers.CustomizeRibbonDialogCustomizationLabel
Return "才上 来锕把"
Case ToolsResourceIdentifiers.CustomizeRibbonDialogCaption
Return "才上 人额女"
Case ToolsResourceIdentifiers.CustomizeQuickAccessLabel
Return "才上 来锕把"
Case ToolsResourceIdentifiers.QuickAccessCustomizeMenu
Return "啊錒别"
Case ToolsResourceIdentifiers.QuickAccessAddItem
Return "啊錒别"
Case ToolsResourceIdentifiers.QuickAccessDialogButtonAdd
Return "啊錒别"
Case ToolsResourceIdentifiers.QuickAccessDialogButtonCancel
Return "锕如如"
Case ToolsResourceIdentifiers.QuickAccessDialogButtonOk
Return "别"
Case ToolsResourceIdentifiers.QuickAccessDialogButtonReset
Return "地方把小"
Case ToolsResourceIdentifiers.QuickAccessDialogButtonRemove
Return "可用呢"
Case ToolsResourceIdentifiers.QuickAccessMinimizeTheRibbon
Return "啊錒别 如额呢"
Case ToolsResourceIdentifiers.QuickAccessPlaceAboveRibbon
Return "錒为你 啊錒别 "
Case ToolsResourceIdentifiers.QuickAccessPlaceBelowRibbon
Return "地方把小 无不的 "
Case ToolsResourceIdentifiers.QuickAccessToolBarLabel
Return "地方把小 无不的 "
Case ToolsResourceIdentifiers.CustomizeRibbonDialogRenameCancelButton
Return "锕如如"
Case ToolsResourceIdentifiers.CustomizeRibbonDialogRenameCaption
Return "如额你啊吗额"
Case ToolsResourceIdentifiers.CustomizeRibbonDialogRenameOkButton
Return "别"
Case ToolsResourceIdentifiers.CustomizeRibbonRenameDisplayLabel
Return "都三片来啊 了阿不"
Case ToolsResourceIdentifiers.CustomizationLabel
Return "都三片来啊 了阿不"
Case ToolsResourceIdentifiers.CustomizeMenu
Return "都三片来啊 了阿不"
Case ToolsResourceIdentifiers.QuickAccessDialogDropDownName
Return "都三片来啊 了阿不"
Case ToolsResourceIdentifiers.QuickAccessCustomizeCaption
Return "都三片来啊 "
Case ToolsResourceIdentifiers.QuickAccessDialogCommands
Return "都三片来啊 "
Case ToolsResourceIdentifiers.CustomizeRibbonDialogColumnHeader
Return "都三片来啊 "
Case ToolsResourceIdentifiers.CustomMenu
Return "都三片来啊 "
Case ToolsResourceIdentifiers.QuickAccessDialogCustomizeRibbon
Return "都三片来啊 "
Case Else
Return String.Empty
End Select
End Function
End Class
Ribbon Resource Identifier
String |
Description |
---|---|
CustomizeRibbonDialogButtonAdd |
`Add` button to add selected item in Customize Ribbon window |
CustomizeRibbonDialogButtonRemove |
`Remove` button to remove selected item in Customize Ribbon window |
CustomizeRibbonDialogButtonCancel |
`Cancel` button to cancel the changes in Customize Ribbon window |
CustomizeRibbonDialogButtonOk |
`Ok` button to save the changes in Customize Ribbon window |
CustomizeRibbonDialogButtonReset |
`Reset` button to reset all the customizations in Customize Ribbon window |
CustomizeRibbonDialogLabel |
Main `Customize the Ribbon` label in Customize Ribbon window |
CustomizeRibbonDialogChooseCommands |
`Choose Commands from` combo box header |
CustomizeRibbonDialogMainTab |
`Customize Ribbon` tab header in left panel in Customize window |
CustomizeRibbonDialogButtonNewGroup |
`New Group` button to add new group in Customize Ribbon window |
CustomizeRibbonDialogButtonNewTab |
`New Tab` button to add new tab in Customize Ribbon window |
CustomizeRibbonDialogButtonRename |
`Rename` button to rename selected item in customize Ribbon window |
CustomizeRibbonDialogCustomizationLabel |
`Customizations` label in customize ribbon window |
CustomizeRibbonDialogCaption |
Caption in customize ribbon window |
CustomizeQuickAccessLabel |
Main label in customize QAT |
QuickAccessCustomizeMenu |
Customize menu in quick access |
QuickAccessAddItem |
Add Item label in quick access |
QuickAccessDialogButtonAdd |
`Add` button to add selected item in Customize QAT window |
QuickAccessDialogButtonCancel |
`Cancel` button to cancel the changes in Customize QAT window |
QuickAccessDialogButtonOk |
`Ok` button to save the changes in Customize QAT window |
QuickAccessDialogButtonReset |
`Reset` button to reset all the customizations in Customize QAT window |
QuickAccessDialogButtonRemove |
`Remove` button to remove selected item in Customize QAT window |
QuickAccessMinimizeTheRibbon |
MinimizeTheRibbon option in quick access |
QuickAccessPlaceAboveRibbon |
PlaceAboveRibbon option in quick access |
QuickAccessPlaceBelowRibbon |
PlaceBelowRibbon option in quick access |
QuickAccessToolBarLabel |
QAT label |
CustomizeRibbonDialogRenameCancelButton |
`Cancel’ button in Rename popup window |
CustomizeRibbonDialogRenameCaption |
Rename caption in rename popup window |
CustomizeRibbonDialogRenameOkButton |
`Ok` button in rename popup window |
CustomizeRibbonRenameDisplayLabel |
Display Name label in rename popup window |
CustomizationLabel |
Customization label in window |
CustomizeMenu |
Customize menu option |
QuickAccessDialogDropDownName |
Drop down name in quick access dialog |
QuickAccessCustomizeCaption |
Customize caption in customizing QAT. |
QuickAccessDialogCommands |
Commands dialog in quick access |
CustomizeRibbonDialogColumnHeader |
Column header in Customize ribbon |
CustomMenu |
Custom menu label |
QuickAccessDialogCustomizeRibbon |
Quick access dialog in customize ribbon window |
Right To Left
In Right To Left support, RibbonControlAdv aligns all its controls from right To left when the ribbon property `RightToLeft’ is set to Yes.
this.ribbonControlAdv1.RightToLeft = RightToLeft.Yes;
this.ribbonControlAdv1.RightToLeft = RightToLeft.Yes;