Internationalization

Since version 2.5, reports can support multiple languages. This is an important aspect of international applications. The goal of this feature is to allow fields and labels to store multiple texts, one for each predefined language.

Adding languages

  • To set the languages, select Report  Report and page settings…​ and choose the Language tab in the dialog.

  • To add more languages, select a language in the combo box and add it to the language list with the Add button.

page settings language

Leave the Default language first in the list. It represents the original language of the report.

  • Set the Multi language role if missing translation option. It determines what happens if a label or field has no translation for the current language: if you choose Use default language, the default text appears; if you choose Leave blank, the label or field is not printed.

Adding translations of Fields or Labels

Insert a Field or Label item as usual. The property dialog contains a tab for each language defined previously. Type the translations into the appropriate language tabs. An empty translation tab means a missing translation.

label properties multi language

Setting up the current language

The current language of the report can be set both in design mode and at runtime. In the Designer, select Report  Report language or the Languages tool button on the toolbar, and choose the language you want from the submenu.

To set the language from application code, use the setCurrentLanguage( const QString& langcode ) function, where langcode is the two-letter ISO language code.

Setting up the language

NCReport* report = new NCReport(parent);
report->setCurrentLanguage("de");

To set the language when running reports from the command line, use the -l (or --language) command line option followed by the two-letter language code.

Setting up the current language from command line

NCReport -f myreport.ncr -l de

The multi-language-invoice-test.xml demo report shows a multi-language report.