[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Collapse]eXpressApp Framework
 [Expand]Getting Started
 [Expand]Design-Time Features
 [Collapse]Task-Based Help
  [Expand]Business Model Design
  [Expand]Application Model
  [Expand]List Editors
  [Expand]Property Editors
  [Expand]Scheduler and Notifications
    How to: Add a Custom Localization Dictionary to a Mobile Application
    How to: Change a Mobile UI Language at Runtime
    How to: Create a Custom Translation Provider for the Localization Tool
    How to: Localize a WinForms Template
    How to: Localize an XAF Application
    How to: Localize Custom String Constants
    How to: Localize XAF Application Items Using XAF Tools
  [Expand]Miscellaneous UI Customizations
  Frequently Asked Questions (FAQ)
 [Expand]API Reference
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
This documentation page describes implementations made in our v17.2 release cycle. To learn about functionality shipping with v18.1, navigate to our updated help file experience at docs.devexpress.com. Learn More

How to: Localize Custom String Constants

This topic demonstrates how to localize custom strings, using confirmation messages as an example. The Application Model has the Localization node, which allows for the localization of various constants. You can use this node to localize any custom strings used in your applications.

For instance, a feature that you implement in your application could use the following code.

Expanded Add Localization Items in the Model Editor

To make the text of the confirmation message above localizable, you can add a LocalizationItem child node to the Localization | Messages node, and specify its Value property in the required language. The following image demonstrates the necessary changes to be done in the Application Model.

In this instance, you can get the required message text from the new node, using the CaptionHelper.GetLocalizedText static method.

If you decide that you will have to localize multiple custom strings, you can add a special LocalizationGroup node to the Localization node, and specify your strings within it. Following our example, call this node Confirmations. The following image demonstrates these changes.

In this instance, use the following code.

The LocalizationGroup node can have a multilevel structure. You can create a complex hierarchy and access a required item by passing the path to the CaptionHelper.GetLocalizedText method. Do not include the Localization node itself to the path. For instance, to access the Localization | Messages | Confirmations | DataChangingConfirmations group, use the "Messages\Confirmations\DataChangingConfirmations" path.

Expanded Export Localization Items from Resource Files

Alternatively, you can add Localization Items from the resource file. Assume you have the following MyResource.resx resource file in your XAF solution.

To export values from this file to the Application Model, implement a Resource Localizer (XafResourceLocalizer descendant).

Here, "MySolution.Module.MyResource" is the resource name. Items from this resource will be added to the Localization | Messages | Confirmations Localization Group. Register this Resource Localizer within a module by adding its type to the ModuleBase.ResourcesExportedToModel collection.

Alternatively, you can register a resource localizer within the overridden ModuleBase.GetXafResourceLocalizerTypes method.

In this instance, you will have an ability to add or remove a localizer in the Application Designer.


Localizer types, which are defined in the current module, are not displayed in the Resources exported to model dialog of the Module Designer. This behavior is by design and specific to the work of the Visual Studio design time environment, which cannot get the list of localizer types of the module itself, because this information is not serializable.

Rebuild the solution and invoke the Model Editor. You will see that items from the MyResource.resx resource are exported to the Application Model.

Now, you can use the CaptionHelper.GetLocalizedText method to access localizable values from your code.

Expanded See Also

Is this topic helpful?​​​​​​​