Global Resources

  • 3 minutes to read

This topic describes the native ASP.NET localization approach.

TIP

In v12.1 and higher, we recommend that you localize your application via the Satellite Resource Assemblies.

A resource file is an XML file that contains strings that can be translated into different languages. Resource files in ASP.NET have a .resx extension. Each localized resource file contains name/value pairs. You can use a text editor to customize a resource file's string values.

LocalizationResxFile

Refer to the following topic in the Visual Studio documentation to learn more about global resource files: ASP.NET Web Page Resources Overview.

Resource Files

DevExpress ASP.NET products ship with a default resource file and numerous localized resource files (one for each culture). The default resource files are listed below.

Product

Default Resource File

Card View

DevExpress_Web_ASPxGridView_v20.2.resx

Data and Image Navigation

DevExpress_Web_v20.2.resx

Data Editors

DevExpress_Web_ASPxEditors_v20.2.resx

Diagram

DevExpress_Web_ASPxDiagram_v20.2.resx

Docking and Popups

DevExpress_Web_v20.2.resx

Gantt

DevExpress_Web_ASPxGantt_v20.2.resx

Grid View

DevExpress_Web_ASPxGridView_v20.2.resx

File Management

DevExpress_Web_v20.2.resx

HTML Editor

DevExpress_Web_ASPxHtmlEditor_v20.2.resx

Multi-Use Site Controls

DevExpress_Web_v20.2.resx

Pivot Grid

DevExpress_Web_ASPxPivotGrid_v20.2.resx

Reporting

DevExpress_XtraReports_v20.2_Web.resx

Rich Text Editor

DevExpress_Web_ASPxRichEdit_v20.2.resx

Scheduler

DevExpress_Web_ASPxScheduler_v20.2.resx

Site Navigation and Layout

DevExpress_Web_v20.2.resx

Spell Checker

DevExpress_Web_ASPxSpellChecker_v20.2.resx

Spreadsheet

DevExpress_Web_ASPxSpreadsheet_v20.2.resx

Tree List

DevExpress_Web_ASPxTreeList_v20.2.resx

Vertical Grid

DevExpress_Web_ASPxGridView_v20.2.resx

A localized resource file name consists of the corresponding default name and a culture name, such as the following:

  • DevExpress_Web_v20.2.resx - the default resource file for DevExpress ASP.NET controls.
  • DevExpress_Web_v20.2.de.resx - a resource file for the German localization of DevExpress ASP.NET controls.

You can download default and translated resources for specific versions of DevExpress controls from the following Knowledge Base Article: Localized resources for DevExpress ASP.NET controls.

Add Global Resources to an Application

Copy localized and corresponding default resource files to the App_GlobalResources folder.

LocalizationResourcesFolder

Note that if the App_GlobalResources folder contains only a localized resource file (DevExpress_Web_v20.2.de.resx), without the corresponding default resource file (DevExpress_Web_v20.2.resx), an exception will occur.

Set an Application Culture

An application culture is defined by the Culture and UICulture properties. You can specify them in the following ways.

Localize an Application for a Specific Culture (regardless of operating system settings)

Set the Culture and UICulture properties to a certain culture ID. You can specify the properties at design time or runtime.

Design Time

  • To set the culture for all pages, add the globalization element to the Web.config file. Set the Culture and uiCulture attributes.

    <system.web>
        <globalization uiCulture="es" culture="es" />
        ...
    </system.web>
    
  • To set the culture for an individual page, set the Culture and UICulture attributes of the @ Page directive.

    <%@ Page UICulture="es" Culture="es" %>
    

Runtime

Override the InitializeCulture() method to specify the Culture and UICulture properties for the page.

protected override void InitializeCulture() {
     var lang = Request.QueryString["lang"];
     if (!string.IsNullOrEmpty(lang)) {
          Culture = lang;
          UICulture = lang;
     }
}
<style type="text/css">
     .lang-btn
     {
          text-decoration: none;
     }
</style>
...
<a class="lang-btn" href="Default.aspx?lang=en">
     <img src="Images/english.png" alt="English" />
</a>
<a class="lang-btn" href="Default.aspx?lang=de">
     <img src="Images/german.png" alt="Deutsch" />
</a>
<a class="lang-btn" href="Default.aspx?lang=es">
     <img src="Images/spanish.png" alt="Spanish" />
</a>

<dx:ASPxGridView ID="ASPxGridView1" ...
</dx:ASPxGridView>

The animation below shows the result.

Localization_InitializeCulture

Localize an Application for Numerous Cultures (based on operating system settings)

  • Provide multiple localization sources within your application for each culture to support.
  • Set the Culture and UICulture properties to auto.

The application automatically determines the operating system's culture information and loads the appropriate assemblies for this culture. You can set the Culture and UICulture properties in any of the ways described above.

<%@ Page UICulture="auto" Culture="auto" %>