Back to Devexpress

XtraLocalizer.QueryLocalizedStringNonTranslated Event

corelibraries-devexpress-dot-utils-dot-localization-dot-xtralocalizer.md

latest7.2 KB
Original Source

XtraLocalizer.QueryLocalizedStringNonTranslated Event

Allows you to obtain resource strings that are not localized for the current locale (culture).

Namespace : DevExpress.Utils.Localization

Assembly : DevExpress.Data.v25.2.dll

NuGet Package : DevExpress.Data

Declaration

csharp
public static event EventHandler<XtraLocalizer.QueryLocalizedStringEventArgs> QueryLocalizedStringNonTranslated
vb
Public Shared Event QueryLocalizedStringNonTranslated As EventHandler(Of XtraLocalizer.QueryLocalizedStringEventArgs)

Event Data

The QueryLocalizedStringNonTranslated event's data class is XtraLocalizer.QueryLocalizedStringEventArgs. The following properties provide information specific to this event:

PropertyDescription
ContainerTypeGets the type of a localizer object or data form shipped as part of a DevExpress UI control.
CultureGets the culture name of ResourceStringID.
InvariantStringGets the culture-independent (invariant) resource string.
IsTranslatedGets whether the resource string is localized (translated) for the current locale (culture).
ResourceStringIDGets 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.
StringIDGets the enumeration member in StringIDType that corresponds to the processed resource string.
StringIDTypeGets the type of the resource string identifier for DevExpress UI controls.
ValueGets or sets the resource string.

The event data class exposes the following methods:

MethodDescription
ToString()Returns a string in the following format: {ResourceStringID}: “{Value}”/“{InvariantString”}.

Remarks

The QueryLocalizedStringNonTranslated event fires for each non-localized resource string (if any). Handle this event to collect non-localized resource strings for further translation.

Example

In this example, the Windows Forms application is localized into German with pre-built satellite resource assemblies available from the DevExpress Localization Service. Localized resources were generated by the DevExpress developer community and may be incomplete. The example demonstrates how to obtain untranslated resources and create a dictionary for further translation.

csharp
using System;
using System.Windows.Forms;
using System.Globalization;
using System.Threading;
using DevExpress.Utils.Localization;
using System.Collections.Generic;

namespace DXApplication22 {
    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.QueryLocalizedStringNonTranslated += XtraLocalizer_QueryLocalizedStringNonTranslated;
            Application.Run(new Form1());
        }
        static Dictionary<string, string> deNotTranslatedResources = new Dictionary<string, string>();
        private static void XtraLocalizer_QueryLocalizedStringNonTranslated(object sender, XtraLocalizer.QueryLocalizedStringEventArgs e) {
            deNotTranslatedResources.Add(e.ResourceStringID, e.InvariantString);
        }
    }
}
vb
Imports System
Imports System.Windows.Forms
Imports System.Globalization
Imports System.Threading
Imports DevExpress.Utils.Localization
Imports System.Collections.Generic

Namespace DXApplication22
    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.QueryLocalizedStringNonTranslated, AddressOf XtraLocalizer_QueryLocalizedStringNonTranslated
            Application.Run(New Form1())
        End Sub
        Private deNotTranslatedResources As New Dictionary(Of String, String)()
        Private Sub XtraLocalizer_QueryLocalizedStringNonTranslated(ByVal sender As Object, ByVal e As XtraLocalizer.QueryLocalizedStringEventArgs)
            deNotTranslatedResources.Add(e.ResourceStringID, e.InvariantString)
        End Sub
    End Module
End Namespace

See Also

XtraLocalizer Class

XtraLocalizer Members

DevExpress.Utils.Localization Namespace