corelibraries-devexpress-dot-utils-dot-localization-dot-xtralocalizer-642563ac.md
Allows you to localize resources of data forms integrated in DevExpress UI controls.
Namespace : DevExpress.Utils.Localization
Assembly : DevExpress.Data.v25.2.dll
NuGet Package : DevExpress.Data
public static event EventHandler<XtraLocalizer.QueryLocalizedStringEventArgs> QueryLocalizedStringContainerResource
Public Shared Event QueryLocalizedStringContainerResource As EventHandler(Of XtraLocalizer.QueryLocalizedStringEventArgs)
The QueryLocalizedStringContainerResource event's data class is XtraLocalizer.QueryLocalizedStringEventArgs. The following properties provide information specific to this event:
| Property | Description |
|---|---|
| ContainerType | Gets the type of a localizer object or data form shipped as part of a DevExpress UI control. |
| Culture | Gets the culture name of ResourceStringID. |
| InvariantString | Gets the culture-independent (invariant) resource string. |
| IsTranslated | Gets whether the resource string is localized (translated) for the current locale (culture). |
| ResourceStringID | Gets the value of the enumeration member in StringIDType that corresponds to the processed resource string, or the value that uniquely identifies the form’s UI element/control. |
| StringID | Gets the enumeration member in StringIDType that corresponds to the processed resource string. |
| StringIDType | Gets the type of the resource string identifier for DevExpress UI controls. |
| Value | Gets or sets the resource string. |
The event data class exposes the following methods:
| Method | Description |
|---|---|
| ToString() | Returns a string in the following format: {ResourceStringID}: “{Value}”/“{InvariantString”}. |
The QueryLocalizedStringContainerResource event fires when a data form that ships as part of a DevExpress UI control (for example, a BookmarkForm in the WinForms Rich Text Editor) requests a resource string for its UI element (input field, list, button, etc.). Handle the event to translate non-localized resource strings or modify existing resources of form elements.
Use the e.ContainerType event parameter to get the type of the data form. The e.ResourceStringID parameter uniquely identifies the form’s UI element/control that requested the resource string ({ContainerType}.{controlName}.{propertyPath}).
The following example demonstrates how to localize the Location button’s caption into German. This button is displayed on the Bookmark Form that ships as part of the WinForms XtraRichEdit control.
using System;
using System.Windows.Forms;
using System.Globalization;
using System.Threading;
using DevExpress.Utils.Localization;
namespace DXApplication {
internal static class Program {
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main() {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
CultureInfo culture = CultureInfo.CreateSpecificCulture("de-DE");
Thread.CurrentThread.CurrentUICulture = culture;
Thread.CurrentThread.CurrentCulture = culture;
// Sets the German culture as the default culture for all threads in the application.
CultureInfo.DefaultThreadCurrentCulture = culture;
CultureInfo.DefaultThreadCurrentUICulture = culture;
XtraLocalizer.QueryLocalizedStringContainerResource += XtraLocalizer_QueryLocalizedStringContainerResource;
Application.Run(new Form1());
}
private static void XtraLocalizer_QueryLocalizedStringContainerResource(object sender, XtraLocalizer.QueryLocalizedStringEventArgs e) {
if (e.ContainerType == typeof(DevExpress.XtraRichEdit.Forms.BookmarkForm)) {
if (e.ResourceStringID == "DevExpress.XtraRichEdit.Forms.BookmarkForm.rgSortBy.Properties.Items3")
if (!e.IsTranslated && Thread.CurrentThread.CurrentCulture.Name == "de-DE")
e.Value = "&Standort";
}
}
}
}
Imports System
Imports System.Windows.Forms
Imports System.Globalization
Imports System.Threading
Imports DevExpress.Utils.Localization
Namespace DXApplication
Friend Module Program
''' <summary>
''' The main entry point for the application.
''' </summary>
<STAThread>
Sub Main()
Application.EnableVisualStyles()
Application.SetCompatibleTextRenderingDefault(False)
Dim culture As CultureInfo = CultureInfo.CreateSpecificCulture("de-DE")
Thread.CurrentThread.CurrentUICulture = culture
Thread.CurrentThread.CurrentCulture = culture
' Sets the German culture as the default culture for all threads in the application.
CultureInfo.DefaultThreadCurrentCulture = culture
CultureInfo.DefaultThreadCurrentUICulture = culture
AddHandler XtraLocalizer.QueryLocalizedStringContainerResource, AddressOf XtraLocalizer_QueryLocalizedStringContainerResource
Application.Run(New Form1())
End Sub
Private Shared Sub XtraLocalizer_QueryLocalizedStringContainerResource(ByVal sender As Object, ByVal e As XtraLocalizer.QueryLocalizedStringEventArgs)
If e.ContainerType Is GetType(DevExpress.XtraRichEdit.Forms.BookmarkForm) Then
If e.ResourceStringID = "DevExpress.XtraRichEdit.Forms.BookmarkForm.rgSortBy.Properties.Items3" Then
If Not e.IsTranslated AndAlso Thread.CurrentThread.CurrentCulture.Name = "de-DE" Then
e.Value = "&Standort"
End If
End If
End If
End Sub
End Module
End Namespace
See Also