Blog

Translated labels in reports

  • 8 January 2019
  • 0 replies
  • 60 views
Translated labels in reports
Userlevel 6
Badge +6
When creating multi-language applications, or applications for companies with customers in different countries, you probably want to translate the report labels too. To translate labels in a report you can retrieve the label transition from a data source, for instance a view. With the Software Factory, you can automatically generate these views with a dynamic concept. In this post we will show you how, by creating a view that returns the column-translations for every language in your project.

To use a view for your report labels, you first need to model a view with an appl_lang_id column as the key and the required labels as columns. The name of the view will have a specific prefix, to be able to recognize the report label views in our dynamic concept. Set the creation method of the view to Template.


Now we can add the dynamic control procedure to generate the template for all report label views. Add a control procedure, set the assignment type to SQL and the code group to Views. Then insert the following code:

code:
declare @prefix varchar(10) = 'rpt_lbl_'

-- Insert prog object item for every report label view
insert into prog_object_item
select
@project_id,
@project_vrs_id,
'view_' + t.tab_id,
@control_proc_id,
100,
@control_proc_id,
@control_proc_id
from tab t
where t.project_id = @project_id
and t.project_vrs_id = @project_vrs_id
and t.tab_id like @prefix + '%'
and t.type_of_table = 1 --View
and t.create_view_method = 2 --Template

-- Insert parameters
...


Download the full code here.

This control procedure will add a template to every program object for views that start with @prefix and creates the required parameters.

Now create a template for this control procedure with the following code:

code:
select *
from (values
[open]'[transl]'[close]
) as transl (
[comma][col]
)


After generating the view code will look like this:

code:
select * 
from (values
( 'DE'
,'Land'
,'Stadt'
,'Adresse'
,'€')
,( 'ENG'
,'Country'
,'City'
,'Address'
,'£')
,( 'NL'
,'Land'
,'Stad'
,'Adres'
,'€')
) as transl (
appl_lang_id
,country
,city
,address
,currency
)


Use this view in your report, filter by the required appl_lang_id, drag the fields on your report and off you go!


0 replies

Be the first to reply!

Reply