VCL subscription: new localization tool coming in next build

ctodx
31 October 2008

clip_image001 We've been working on a new tool for native Delphi and C++Builder developers and will release it in the next build (build 40). It's known, catchily, as the TcxLocalizer component. Oh, and it's free with the subscription.

WAY COOL UPDATE: I totally misinterpreted the information I was given. Apparently TcxLocalizer is going to be shipped with the "Express Cross Platform Library" which is included as part of all our active latest products. So you don't need the subscription, you'll, well, just get it anyway, provided you're up to date. And a little birdie tells me that Build 40 is on target for release next week. With that, back to your normal programme...

The TcxLocalizer component helps you localize those of your applications that use our controls, as well as third-party or standard controls. This component provides centralized control over an application’s UI language or locale. Using this component, switching to another locale is as simple as changing a single option.

Here's how it works -- the brief version.

Create a resource string file using the Localizer Editor, which is a standalone application shipped with the component. You then drop the TcxLocalizer component onto a form, link the resource string file to it, and select the current locale.

clip_image003

At this point, you can just run the application and see it localized. Voilà!

Localizing Developer Express controls

With our controls, the text displayed by various UI elements is provided by resource strings. Prior to the TcxLocalizer component, you had to go and manually change resource string values with the translated text. Now, you can use the Localizer Editor to browse all the available resource strings for our controls, specify resource string values for any number of locales, and store these values to a resource strings file.

clip_image005

clip_image007

After this, the created file can be linked to the TcxLocalizer component, and at runtime, the controls will display the text based on the selected locale.

clip_image009

Localizing standard or third-party controls

Along with the configured TcxLocalizer component that you use in the application, specify the IdxLocalizerListener interface for the control to be translated (whether that is a form, frame, or custom control), and implement the IdxLocalizerListener.TranslationChanged method. In this method, perform all the necessary modifications to the UI, such as label and caption initializations, etc.

Of course, you are free to programmatically assign string constants based on the current locale specified by the TcxLocalizer component, however the Localizer Editor provides a more convenient and elegant way to accomplish this. You can define custom resource strings with unique names, store them to a resource strings file, and later retrieve them in the TranslationChanged method.

clip_image011

This way, you can control and modify all the resource strings used in your applications in a centralized manner.

The following example demonstrates how a form’s caption and some labels are localized using resource strings from a resource strings file created with the Localizer Editor.

// Delphi
// ...
uses
cxLocalization, dxCore, cxClasses, ;
type
TForm1 = class(TForm, IdxLocalizerListener)
// ...
public
procedure TranslationChanged;
end;
// ...
procedure TForm1.TranslationChanged;
begin
Caption := cxGetResourceString(@sMainFormCaption);
lblDescription.Caption := cxGetResourceString(@sDescription);
lblFileLocation.Caption := cxGetResourceString(@sFileLocation);
// ...
end;

Free DevExpress Products - Get Your Copy Today

The following free DevExpress product offers remain available. Should you have any questions about the free offers below, please submit a ticket via the DevExpress Support Center at your convenience. We'll be happy to follow-up.
No Comments

Please login or register to post comments.