Skip to main content
A newer version of this page is available. .

How to: Localize a WinForms Template

  • 3 minutes to read

This topic demonstrates how to localize a WinForms Template using the Model Editor. You can customize custom and built-in WinForms templates. Both of these cases are considered in this topic.

Localize a Built-In WinForms Template

To do the translation manually, either directly in the Model Editor or using the Localization Tool, the culture-specific resources should be exported to the Application Model.

  • Invoke the Application Designer.
  • In the Properties window, press the ellipsis button of the ResourcesExportedToModel property (see XafApplication.ResourcesExportedToModel). In the invoked dialog, check the templates you want to localize. Submit the selection by pressing the OK button.

    ResourcesExportedToModel

  • Invoke the Model Editor for the current application project. In the Localization node, you will find child nodes corresponding to the selected resources. Localize them, as with any other XAF string.

    LocalizeTemplates_ModelEditor

As an alternative, you can add localizable resources in the Module Designer. To do this, use the module’s ModuleBase.ResourcesExportedToModel property.

Localize a Custom WinForms Template

It is assumed that you have created a custom template, as described in the How to: Create a Custom WinForms Ribbon Template topic. However, a similar approach is applicable to any other custom WinForms Template (e.g., created in accordance with the How to: Create a Custom WinForms Standard Template ).

LocalizeCustomTemplate

Follow the steps below to make localization items related to your custom template available in the Application Model.

  • Inherit the FrameTemplateLocalizer<T> class. Pass your custom template type (e.g., DetailRibbonForm1) as the generic parameter.

    using DevExpress.ExpressApp.Win.Templates;
    // ...
    public class MyTemplateLocalizer : FrameTemplateLocalizer<DetailRibbonForm1> { }
    
  • In the WinApplication descendant’s constructor, add the MyTemplateLocalizer to the XafApplication.ResourcesExportedToModel list.

    public partial class MySolutionWindowsFormsApplication : WinApplication {
        public MySolutionWindowsFormsApplication () {
            InitializeComponent();
            this.ResourcesExportedToModel.Add(typeof(MyTemplateLocalizer));
        }
        // ...
    }
    
  • In the code-behind file of your custom template (e.g., DetailRibbonForm1.Designer.cs), find the line where the resources private field is declared and initialized.

    System.ComponentModel.ComponentResourceManager resources = 
        new System.ComponentModel.ComponentResourceManager(typeof(DetailRibbonForm1));
    

    Replace the ComponentResourceManager type with XafComponentResourceManager.

    DevExpress.ExpressApp.Win.Templates.XafComponentResourceManager resources = 
        new DevExpress.ExpressApp.Win.Templates.XafComponentResourceManager(typeof(DetailRibbonForm1));
    
  • Rebuild the solution and run the Model Editor. Expand the Localization | FrameTemplates | DetailRibbonForm1 node. The localization items related to your custom templates are available here.

    LocalizeCustomTemplateME

    You can localize these items using the standard approach described in the Localization Basics topic.