Skip to main content
Administrator Guide
Last Updated: 2024-11-15
Example: Create a Report Design With Dynamic Translation Based on Preferred Locale

Example: Create a Report Design With Dynamic Translation Based on Preferred Locale

This example illustrates how to use scripts to dynamically translate label text on custom reports based on the worker's preferred locale instead of the language preference of the user who prints the report.
Your HR department wants you to create a report design for a new hire letter that prints a custom report with the translated text based on the worker's locale preference. You need to create a custom report in Workday and run the report for the worker Logan McNeil, whose account has the preferred locale set to French (Canada).
  1. Create a report design for a new hire letter. See Example: Create a Report Design for a Letter.
  2. Configure the preferred locale for the new hire letter report:
    1. Sign in to your Workday GMS tenant.
    2. Access the
      Edit Custom Report
      task.
    3. From the
      Report Name
      prompt, select
      My New Hire Report
      .
    4. On the
      Columns
      tab, add a row and specify these values:
      Business Object
      Field
      Column Heading Override
      Column Heading Override XML Alias
      Employee
      Preferred Locale
      Locale
      Locale
    5. Click
      OK
      and
      Done
      .
  3. Configure the locale preferences of the worker Logan McNeil:
    1. Sign in to the Workday GMS tenant as Logan McNeil:
      lmcneil
      .
    2. In
      My Account
      Change Preferences
      , set the
      Preferred Locale
      prompt to
      Français (Canada)-fr_CA
      .
    3. Click
      OK
      and
      Done
      .
    4. Sign out of this account.
  4. Open Report Designer in Workday Studio.
  5. Create a report project named
    Translation With Scripts
    .
  6. Move or copy the
    New Hire Letter.rptdesign
    report file you created earlier and place it in the
    Translation With Scripts
    project.
  7. Create a Workday data source and download some sample data:
    1. Create a new
      Workday Report Data Source
      named
      New Hire Letter Data Source
      .
    2. Download the report description for the
      My New Hire Letter Report
      custom report from Workday.
    3. Download sample report data from Workday and name the file
      New Hire Letter.xml
    4. Select
      Report Parameters
      Select literal values
      Select Worker Instances
      and specify
      Worker
      instances to include in the report, then click
      OK
      .
    5. Click
      Download
      and
      Test Connection
      .
    6. When the Report Designer displays a
      Success
      message, click
      OK
      and
      Finish
      .
  8. Create a new data set with these values:
    Option
    Value
    Data Source Selection
    New Hire Letter Data Source
    Data Set Type
    Workday Primary Report Data Set
    Data Set Name
    Employees
    1. Add this text to the resource file:
      Dear=Dear
      Congratulations=Congratulations on joining our team. We are excited to have you!
      Terms=Your employment with our Company includes the following agreed upon terms:
      Date_of_Hire=Date of Hire:
      Business_Title=Business Title:
      Manager_Name=Manager Name:
      Organization=Organization:
      Location=Location:
      Amount=Base Pay Amount:
      Disclaimer=Please be advised that your employment with the Company will be "at will", which means that either you or the Company may terminate your employment at any time, for any reason or no reason, with or without notice. There is no promise by the Company that your employment will continue for a set period of time or that your employment will be terminated only under peculiar circumstances.
      Sincerely=Sincerely,
    2. Name the resource file
      translation.properties
      .
    1. Add tis text to the resource file:
      Dear=Cher(ère)
      Congratulations=Félicitations pour avoir rejoint notre équipe. Nous sommes ravis de vous compter parmi nous!
      Terms=Votre emploi au sein de notre entreprise est soumis aux conditions suivantes :
      Date_of_Hire=Date d'embauche :
      Business_Title=Titre professionnel :
      Manager_Name=Nom du gestionnaire :
      Organization=Organisation :
      Location=Emplacement :
      Amount=Montant du salaire de base :
      Disclaimer=Veuillez noter que votre emploi au sein de la Société sera « à volonté », ce qui signifie que vous ou la Société pouvez mettre fin à votre emploi à tout moment, pour quelque raison que ce soit ou sans raison, avec ou sans préavis. La Société ne promet aucunement que votre emploi se poursuivra pendant une période de temps déterminée ou que votre emploi prendra fin uniquement dans des circonstances particulières.
      Sincerely=Sincèrement,
    2. Name the resource file
      translations_fr_CA.properties
      .
  9. Associate the resource files with the report design file:
    1. In the
      Property Editor - Report
      view, select the
      Resources
      tab.
    2. Click
      Add File...
      and add these files to the
      Properties Files
      list:
    • translations.properties
    • translations_fr_CA.properties
  10. Add the
    onCreate
    script for the translatable text for each label report item:
    1. In the
      Layout
      view of your design, click the
      Dear
       label.
    2. From the
      Script
      tab, select
      onCreate
      from the
      Scripts
      list.
    3. In the text pane, add this script for the label:
      importPackage(Packages.java.util); if(row["Locale"]=="fr_CA") { var lc = new Locale("fr_CA"); this.text = reportContext.getMessage("Dear", lc);}
    4. Repeat steps a. through c. for each label that requires dynamic translation.
    5. Save your work.
      You can check whether there's a script associated with a label report item in the
      Advanced
      tab in
      Property Editor
      .
  11. To access the preferred locale for each worker at runtime, add a table to the layout:
    1. In the
      Outline
      view, right-click the
      Body
      node, then select
      Insert Element
      .
    2. Double-click the
      Table
      element and configure these values:
      Number of columns
      1
      Number of details
      1
      Number of details
      Employees
      You only need the detail row of your table. To delete the header and footer rows, right-click in the row guide cell, then select
      Delete
      .
  12. Move the existing report items from the
    Body
    node in the
    Outline
    view to
    Detail Row
    in the table:
    1. Expand
      Detail Row
      down to the
      Cell
      level.
    2. Select the nodes below the
      Body
      node that you want to move by pressing the
      Shift
      key, followed by the
      Image
      node, and the last
      Data
      node.
    3. Right-click and select
      Cut
      , then right-click on the detail row
      Cell
      node and select
      Paste
      .
  13. Save and preview your design.
When you print the
My New Hire Letter Report
for
Logan McNeil
, the
onCreate
scripts translate the label text in the report into French, using the key values in the
translations_fr_CA.properties
file.
Deploy your design to Workday for use as business form layout.