VCL Shared Framework

Application Localization

A new localization component - TcxLocalizer - allows you to easily localize applications that use standard, DevExpress or other third-party controls to any language supported by Windows.

With TcxLocalizer, the simplest way to localize your application is the following:

  • Create a resource strings file using the Localizer Editor (a standalone application shipped with the component).
  • Drop the TcxLocalizer component onto a form and link it to the resource strings file.
  • Make certain that the TcxLocalizer.Active property is True.
  • Now you can switch the current locale using a single property.

Localizing Developer Express Controls

In our controls, the text displayed in UI elements is stored as resource strings. Prior to the TcxLocalizer component, you had to manually change resource string values. Now, you can use the Localizer Editor to browse all available resource strings for our controls, specify resource string values for any number of locales and store these values to a resource strings file. Note that you can store Unicode strings and use them in applications built with Delphi/C++ Builder 2009.



After you've specified all required values, the created resource strings file can be linked to the TcxLocalizer component. At runtime, DevExpress controls will display text depending upon the current locale.

Localizing Standard or Third-Party Controls

When using standard or third-party components, add support for the IdxLocalizerListener interface, register components with the built-in instance of the TdxResourceStringsRepository as listeners, and implement the interface's TranslationChanged method. In this method, update the control's content using the current locale's strings.

You are free to programmatically assign string constants based on the current locale specified by the TcxLocalizer component. The Localizer Editor, however, provides a more elegant way to accomplish this. You can define custom resource strings with unique names, specify their translations for required languages, and retrieve these translations in the TranslationChanged method.

The following code example demonstrates how a form's caption and a few labels are localized using resource strings defined with the help of the Localizer Editor.

[Delphi]

uses
  cxLocalization, dxCore, cxClasses, CustomResourceStringsUnit;
type
  TForm1 = class(TForm, IdxLocalizerListener)
  cxLocalizer1: TcxLocalizer;
  procedure FormCreate(Sender: TObject);
  procedure FormDestroy(Sender: TObject);

// ...
  public
    procedure TranslationChanged;
  end;
// ...

implementation
// ...

  procedure TForm1.FormCreate(Sender: TObject);
  begin
    dxResourceStringsRepository.AddListener(Self);
  end;

  procedure TForm1.FormDestroy(Sender: TObject);
  begin
    dxResourceStringsRepository.RemoveListener(Self);
  end;

  procedure TForm1.TranslationChanged;
  begin
    Caption := cxGetResourceString(@sMainFormCaption);
    lblDescription.Caption := cxGetResourceString(@sDescription);
    lblFileLocation.Caption := cxGetResourceString(@sFileLocation);
    // ...
  end;
Supported DevExpress Products

Codeless UI localization is supported by the following DevExpress VCL Products:

  • ExpressBars 6
  • ExpressQuantumGrid 6
  • ExpressScheduler 3
  • ExpressQuantumTreeList 4
  • ExpressLayout Control
  • ExpressVerticalGrid
  • ExpressPivotGrid 2
  • ExpressSpellChecker
  • ExpressSpreadSheet
  • ExpressNavBar 2
  • ExpressPrinting System
  • ExpressSkins Library
LIVE CHAT

Chat is one of the many ways you can contact members of the DevExpress Team.
We are available Monday-Friday between 7:30am and 4:30pm Pacific Time.

If you need additional product information, write to us at info@devexpress.com or call us at +1 (818) 844-3383

FOLLOW US

DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, ASP.NET, WinForms, HTML5 or Windows 10, DevExpress tools help you build and deliver your best in the shortest time possible.

Copyright © 1998-2017 Developer Express Inc.
All trademarks or registered trademarks are property of their respective owners