Display translated object data
Some object class properties of the type String and Text can be translated to the secondary languages for which the Support Data Translation attribute is set to True in the culture settings.
When a property is translatable, the translation is written to the database table column "<property tech name>_<language code>"
For configured reports of the type Query the translated object data is automatically displayed in the report in the language currently displayed in the user interface. For native SQL queries the change to the current language must be explicitly configured within the native SQL query.
The following configuration is required:
- The code /*CULTURE_CODE*/ must be added after the object class property specification in the native SQL query.
- In SELECT statements, an alias must be defined for the column name of the dataset column containing the translated values.
- The object class property value is displayed automatically in the language currently selected for display of the Alfabet user interface.
If no data translation is configured for the current language for rendering the interface, the culture code setting will be ignored and the original language is used for display of results.
If the current language for rendering the interface is configured to provide data translation, but no translation is provided, the respective cell in the result dataset is empty. To fall back to the original language if no translation is provided, the query should be defined with a condition that checks whether the translation is empty and displays the original language if applicable. For example: ISNULL(APPLICATION.NAME/*CULTURE_CODE*/, APPLICATION.NAME) AS NAME as column definition in the SELECT statement. This is also relevant for specification of conditions refering to filter fields that may return values in either original or current language.
The following query defines a dataset that displays the name and description of applications in the current language with a fallback to the original language. A WHERE condition refering to a filter field is also added:
- SELECT app.REFSTR, ISNULL(app.NAME/*CULTURE_CODE*/, app.NAME) AS NAME, ISNULL(app.DESCRIPTION/*CULTURE_CODE*/, app.DESCRIPTION) AS DESCRIPTION
- FROM APPLICATION app
- WHERE ISNULL(app.NAME/*CULTURE_CODE*/, app.NAME) LIKE @QUERY