XafApplication.CustomizeLanguage Event

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

Namespace: DevExpress.ExpressApp

Assembly: DevExpress.ExpressApp.v18.2.dll

Declaration

public event EventHandler<CustomizeLanguageEventArgs> CustomizeLanguage
Public Event CustomizeLanguage As EventHandler(Of CustomizeLanguageEventArgs)

The event handler receives an argument of the CustomizeLanguageEventArgs type.

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.

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 += new EventHandler<CustomizeLanguageEventArgs>(
         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

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";
    }
    //...
}

Mobile

using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Mobile;
// ...
public partial class MySolutionMobileApplication : MobileApplication {
    // ...
    public MySolutionMobileApplication() {
        // ...
        CustomizeLanguage += MySolutionMobileApplication_CustomizeLanguage;
    }
    private void MySolutionMobileApplication_CustomizeLanguage(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