windowsforms-3096-build-an-application-application-skins-how-to-localize-bar-and-ribbon-skin-items.md
You can utilize a Localizer object to customize skin menus, instead of iterating through each Bar skin sub-menu item and Ribbon skin gallery item container to manually modify the items. This approach allows you to customize skin items in all existing bar sub-menus and Ribbon galleries simultaneously.
Create a BarLocalizer class descendant and override its virtual XtraLocalizer<T>.GetLocalizedString method.
Use the static BarLocalizer.Active property to set a new instance of your custom class as the current bar localizer. Call this method in the Program class before the Application.Run method call, as shown below.
Run the application to see the result.
Important
If the custom localizer is assigned after a bar skin sub item, or if the Ribbon skin gallery is already initialized (for example, on the Load event), skin items will display default captions. In this case, call static SkinHelper.InitSkinPopupMenu and SkinHelpber.InitSkinGallery methods to initialize skin items again and activate the localizer.
void ucBar_Load(object sender, EventArgs e) {
BarLocalizer.Active = new MyBarLocalizer();
//refresh bar sub-item links
skinBarSubItem1.ClearLinks();
SkinHelper.InitSkinPopupMenu(skinBarSubItem1);
//refresh Ribbon gallery links
SkinHelper.InitSkinGallery(skinRibbonGalleryBarItem1);
}
Private Sub ucBar_Load(ByVal sender As Object, ByVal e As EventArgs)
BarLocalizer.Active = New MyBarLocalizer()
'refresh bar sub-item links
skinBarSubItem1.ClearLinks()
SkinHelper.InitSkinPopupMenu(skinBarSubItem1)
'refresh ribbon gallery links
SkinHelper.InitSkinGallery(skinRibbonGalleryBarItem1)
End Sub
See Also