vcl-dxreport-dot-tdxreport-f04a6394.md
Specifies the required language (for UI and report localization).
property Language: string read; write;
| Type | Description |
|---|---|
| string |
The target culture name for UI and report localization.
You can use any ISO-based culture identifier to select the corresponding available localization.
|
Use the Language property to switch between available languages for the Report Designer/Report Viewer UI and report layouts/resulting reports.
Web-based Report Designer and Report Viewer end-user dialogs available for the TdxReport component support JSON localization strings obtained from the DevExpress Localization Service.
Refer to the following help topic for detailed instructions: Report Viewer and Designer UI Localization.
The Language property allows you to switch between multiple languages for a report if corresponding localized values are stored in the report template layout (in the XML-like REPX format).
Refer to the following help topic for detailed information on report content localization: Report Localization.
View Example: Localize the DevExpress Viewer and Report Designer
The code example in this section demonstrates three button OnClick event handlers that allow users to switch between the base language (English) and two localizations (Greek and Italian). Once the TdxReport.Language property value is changed, Report Designer and Report Viewer dialogs use the corresponding localization when displayed the next time.
uses
dxReport; // Declares the TdxReport class
// ...
procedure TMyForm.btnEnglishClick(Sender: TObject);
begin
dxReport1.Language := 'en-US';
end;
procedure TMyForm.btnGreekClick(Sender: TObject);
begin
dxReport1.Language := 'el-GR';
end;
procedure TMyForm.btnItalianClick(Sender: TObject);
begin
dxReport1.Language := 'it-IT';
end;
#include "dxReport.hpp" // Declares the TdxReport class
// Add the following linker directive to the corresponding CPP source file:
#pragma link "dxReport" // Required to use dxReport.hpp declarations
void __fastcall TMyForm::btnEnglishClick(TObject *Sender)
{
dxReport1->Language = "en-US";
}
void __fastcall TMyForm::btnGreekClick(TObject *Sender)
{
dxReport1->Language = "el-GR";
}
void __fastcall TMyForm::btnItalianClick(TObject *Sender)
{
dxReport1->Language = "it-IT";
}
This code example loads an XML-based report template (REPX) from a dataset, configures export settings, populates the template with data from another dataset, and displays the report preview:
uses
dxReport, // Declares the TdxReport component and related types
dxBackend.ConnectionString.JSON.DataSet; // Declares the TdxBackendDataSetJSONConnection component
// ...
procedure TMyForm.Button1Click(Sender: TObject);
var
ADataConnection: TdxBackendDataSetJSONConnection;
AReport: TdxReport;
ALayoutStream: TStream;
begin
ADataConnection := TdxBackendDataSetJSONConnection.Create(Self);
try
ADataConnection.Name := 'DataSetJSONData';
ADataConnection.DataSets.Add('Data', FDataSource);
AReport := TdxReport.Create(Self);
try
AReport.ReportName := 'Report';
ALayoutStream := FLayoutDataSet.CreateBlobStream(FLayoutDataSet.FieldByName('Layout'), bmRead);
try
AReport.Layout.LoadFromStream(ALayoutStream);
finally
ALayoutStream.Free;
end;
AReport.Language := 'fr-FR';
AReport.ExportFormats := [TdxReportExportFormat.PDF,
TdxReportExportFormat.RTF, TdxReportExportFormat.HTML];
AReport.FilterString := 'id = 5';
AReport.ShowViewer;
finally
AReport.Free;
end;
finally
ADataConnection.Free;
end;
end;
#include "dxReport.hpp" // Declares the TdxReport component and related types
#include "dxBackend.ConnectionString.JSON.DataSet.hpp" // Declares the TdxBackendDataSetJSONConnection component
// Add the following linker directives to the corresponding CPP source file:
#pragma link "dxReport" // Required to use dxReport.hpp declarations
#pragma link "dxBackend.ConnectionString.JSON.DataSet" //Required to use TdxBackendDataSetJSONConnection declarations
// ...
void __fastcall TMyForm::Button1Click(TObject *Sender)
{
TdxBackendDataSetJSONConnection *ADataConnection;
TdxReport *AReport;
TStream *ALayoutStream;
ADataConnection = new TdxBackendDataSetJSONConnection(this);
try
{
ADataConnection->Name = "DataSetJSONData";
ADataConnection->DataSets->Add("Data", FDataSource);
AReport = new TdxReport(this);
try
{
AReport->ReportName = "Report";
ALayoutStream = FLayoutDataSet->CreateBlobStream(FLayoutDataSet->FieldByName("Layout"), bmRead);
try
{
AReport->Layout->LoadFromStream(ALayoutStream);
}
__finally
{
delete ALayoutStream;
}
AReport->Language = "fr-FR";
AReport->ExportFormats = TdxReportExportFormats() << TdxReportExportFormat::PDF
<< TdxReportExportFormat::RTF << TdxReportExportFormat::HTML;
AReport->FilterString = "id = 5";
AReport->ShowViewer();
}
__finally
{
delete AReport;
}
}
__finally
{
delete ADataConnection;
}
}
The Language property’s default value is an empty string.
The default Language property value indicates the en-US culture.
See Also