Localize Standard XAF Modules and DevExpress Controls Used in an Application
- 5 minutes to read
The standard XAF modules and DevExpress controls supply most of the English texts an XAF application's interface uses. The DevExpress .NET Localization Service provides the ready-to-use translations of these texts into different languages - ASP.NET resources (required for an ASP.NET application) and satellite assemblies (required for WinForms and ASP.NET platforms). This topic describes how to use these translations in your application and how to manually localize standard XAF Modules and DevExpress controls when there are no ready-to-use translations for your language.
Satellite Assemblies for DevExpress Controls and XAF Modules
You can install pre-built satellite assemblies in the Global Assembly Cache (GAC) to avoid translating texts supplied with DevExpress controls and XAF Modules. Satellite assemblies for de, es, ja and ru languages are installed in %PROGRAMFILES(x86)%\DevExpress 20.2\Components\%PROGRAMFILES(x86)%\DevExpress 20.2\.NET Core Desktop Libraries\Bin folder and GAC. You can download satellite assemblies for other cultures from the DevExpress Localization Service. Refer to the How to register an assembly in the GAC KB article for more information on how to manually register satellite assemblies in the GAC.
Ensure that the Languages key from the configuration file's appSettings section contains all the languages your application supports:
<configuration> <appSettings> <!-- ... --> <add key="Languages" value="en;de;fr" /> <!-- ... --> </appSettings> <!-- ... --> <configuration>
You can handle the XafApplication.CustomizeLanguagesList event as an alternative to the configuration setting above.
Localization Using the Localization Service
The Localization Service allows you to download and modify satellite assemblies. Set the .NET Platform to XAF to translate only XAF-specific values. Follow the steps from the Localization Service topic to localize XAF Modules. Note the following restrictions:
- This service does not allow modifying default language text values.
- You can translate values for XPO classes from the Business Class Library only.
- Because the XAF Application Model has a tree-like structure, the Name column displays property names in a different format that contains a path to the property and property name. For example, the Application | Views | Person_DetailView node's Tooltip property has the "Application\Views\Person_DetailView\Tooltip" name in this table.
- Check Show Calculated Values to show items that do not require translation: calculated values, items without a value in a default language, Domain Components from the Business Class Library, and values that contain property names (for example, ObjectCaptionFormat, DisplayFormat).
Calculated values are translated automatically based on the non-calculated values' translation. Input "non-calculated" in the search panel to show only the non-calculated values.
- An item is only translated if it has a text value; otherwise, you can add a value for the target language or leave it blank.
Values containing properties' names (ObjectCaptionFormat, DisplayFormat, etc.) should not be localized. ObjectFormatter processes these values and replace properties' names with the corresponding values.
If you received the FormatException or MemberNotFoundException, ensure that you have not replaced a property name with a localized value.
If the approach described in the section above does not apply you, follow the instructions from the How to: Localize XAF Application Items Using XAF Tools topic.
Culture-specific resources should be exported to the Application Model when you localize DevExpress Controls.
- Invoke the Application Designer.
In the Properties window, click the XafApplication.ResourcesExportedToModel property's ellipsis button. In the invoked dialog, check the resources you want to localize. Click OK to submit the selection.
Invoke the Model Editor for the current application project and localize the Localization node's child nodes.
You can also use the module's ModuleBase.ResourcesExportedToModel property to add localizable resources in the Module Designer. The resources added in a module cannot be removed from the localizable resources list in another module or application. For example, if you added the resources in the base Module, these resources are used in a platform-specific Modules, but you cannot delete these resources from the platform-specific Module.
Certain components added to a Model require a reference. For instance, after adding the XtraGrid Control to the Model, you get the following error: "The type 'DevExpress.XtraGrid.Localization.GridResLocalizer' is defined in an assembly that is not referenced. You should add a reference to assembly 'DevExpress.XtraGrid.v20.2...". Add a reference to the required assembly to resolve this issue.
Reuse Your Translations
You can use one of the following approaches to reuse translations in different XAF applications:
- Localize all standard XAF module captions using the Model Editor invoked for the application project and share the resulting XAFML files with translations;
- Create a new XAF module and localize all standard XAF module captions using the Model Editor invoked for its Model.DesignedDiffs.xafml file as described in the How to: Localize XAF Application Items Using XAF Tools topic. You can now use the Module or Application Designers to reuse this module in other applications.