Skip to main content
.NET Framework 4.6.2+

XafApplication.CustomizeLanguage Event

Occurs after a language has been set for the application internally.

Namespace: DevExpress.ExpressApp

Assembly: DevExpress.ExpressApp.v24.2.dll

NuGet Package: DevExpress.ExpressApp

Declaration

public event EventHandler<CustomizeLanguageEventArgs> CustomizeLanguage

Event Data

The CustomizeLanguage event's data class is CustomizeLanguageEventArgs. The following properties provide information specific to this event:

Property Description
LanguageName Specifies the language currently used by the application.
PreferredLanguageName Specifies the language currently set for the Application Model‘s IModelApplication.PreferredLanguage property.
UserLanguageName Specifies the language which is set in the user’s operating system or passed by the Internet browser.

Remarks

Handle this event to set the required language to be used by the application. To get the language currently set, use the handler’s CustomizeLanguageEventArgs.LanguageName property. In addition, you can get the language which is set in the user’s operating system or passed by the Internet browser. For this purpose, use the handler’s CustomizeLanguageEventArgs.UserLanguageName property. To get the language which is currently set for the Application node’s IModelApplication.PreferredLanguage property, use the handler’s CustomizeLanguageEventArgs.PreferredLanguageName property. Note that the language you set in this event handler cannot be changed via the Application Model at runtime.

The following code snippets demonstrate how to set German, instead of the default language.

WinForms

using System;
using DevExpress.ExpressApp;
//...
static class Program {
   public static void Main() {
      //...
      MySolutionWindowsFormsApplication application = new MySolutionWindowsFormsApplication(); 
      application.CustomizeLanguage += application_MyLanguage;
      // ...
   }
   private static void application_MyLanguage(object sender, CustomizeLanguageEventArgs e) {
      e.LanguageName = "de";
      //To use the default (English) language, use the following code line instead:
      //e.LanguageName = "en";
   }
}

ASP.NET Web Forms

using System;
using System.Collections.Generic;
using System.Configuration;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Web;
//...
public class Global : System.Web.HttpApplication {
    protected void Session_Start(Object sender, EventArgs e) {       
        WebApplication.Instance.CustomizeLanguage += 
            new EventHandler<CustomizeLanguageEventArgs>(instanse_MyLanguage);
        //...
    }
    private static void instanse_MyLanguage(object sender, CustomizeLanguageEventArgs e) {
        e.LanguageName = "de";
        //To use the default (English) language, use the following code line instead:
        //e.LanguageName = "en";
    }
    //...
}

Of course, you should localize properties in the “de” language before running the application with the code above. Otherwise, the default (English) language will be used.

You can use the IModelApplication.PreferredLanguage property of the Application Model’s Application node to set a language, if you do not use any conditions to determine the language the application should use.

See Also