Report Translations

Document Creator includes a Report Translations feature which helps to create multilingual reports adding translations as data. The report developer can simply add label placeholders in the report object which automatically populate the Document Creator Translation table. You can configure the settings of the Report Translations feature in the Translations group of the Document Creator Setup page, see Translation Settings.

Benefits:

  • Translations are no longer in code, but have become data
  • Non-existing translation records will automatically be created
  • Translation is no longer restricted to the (AL) extension developer
  • Translations can be created or modified by the end-user as well

Editing TranslationsLink

On the Document Creator Translations page you can view, create and edit translations that can be used by reports. By default, the page shows the following columns in the main page:

Column Description
Tag The source text/label placeholder to translate.
Default Translation The translation for language code ''.
To-do Specifies whether the Tag still needs a Default Translation.
To-do exists Specifies whether there is a translation record with a To-do for any language for the Tag. The translations of the Tag can be found in the Document Creator Translations subpage.
Report ID If empty, the translations will be used by all reports. If not empty, the translations will be used as report-specific translations for the report object with the specified ID.
Report Caption The report caption of the report to which the translations apply.
Last Used Specifies when the translation was last used. Whether or not this field is updated depends on the Update Usage setting.
Last Used by Report ID Specifies the ID of the report that last used the translation. Whether or not this field is updated depends on the Update Usage setting.

document-creator-translations

The subpage can be used to enter translations for any language you wish to support.

Info

The Document Creator Translations page also features a Copy... action that can be used to copy translations as report-specific translations or copy translations for one language code to translations for another language code.

Tip

Document Creator ships with a RapidStart package that already provides you with a set of translations for multiple languages. This package also provides the translations for the W1 Report Templates. See Templates.

Adding Translatable Labels to Report ObjectsLink

Warning

The following section provides details on how an (AL) extension could utilize the Report Translations feature in the report object definition. Some prior knowledge on extension development is expected.

Many document types in Dynamics 365 Business Central have a "Language Code" in the document header. To translate report labels to the document language and automatically retrieve the translations and/or populate the Document Creator Translation table with To-do's you can use the wDCR_TranslationMgt codeunit in your report object. For an example, please see the report objects in the W1 Report Templates extension.

First add the following needed global variables:

var
    Language: Codeunit Language;
    wDCR_TranslationMgt: Codeunit wDCR_TranslationMgt;
    ReportId: Integer;

Add the following code in the OnAfterGetRecord trigger of the document header dataitem, which updates the current report language and passes the "Language Code" of the document to the wDCR_TranslationMgt codeunit:

trigger OnAfterGetRecord()
begin
    CurrReport.Language := Language.GetLanguageIdOrDefault("Language Code");
    wDCR_TranslationMgt.wgFncSetLanguageCode("Language Code");
    // ...
end;

Add the following local procedure that can be used to retrieve translations for the report:

local procedure Trl(pLblName: Text[50]): Text
begin
    if ReportId = 0 then begin
        Evaluate(ReportId, DelChr(CurrReport.ObjectId(false), '=', DelChr(CurrReport.ObjectId(false), '=', '1234567890')));
        wDCR_TranslationMgt.wgFncSetReportId(ReportId);
    end;
    exit(wDCR_TranslationMgt.wgFncTranslate(pLblName));
end;

You can then use the Trl local procedure in the expression of a report column to add a translatable label to the dataset, e.g.:

column(lblAllowInvDisc; Trl('AllowInvDisc')) { }
column(lblAmount; Trl('Amount')) { }
column(lblBankAccNo; Trl('BankAccNo')) { }
column(lblBankName; Trl('BankName')) { }
// ...