Table of Contents

Article

Localizing a warning message from a Directed Web Access link

When your application users use Directed Web Access (DWA) for a Pega Survey, you want them to see a warning message that is localized for their locale when they close the survey. In the example provided here, the English language pyCaption warning message that is displayed when users close the survey is localized for German.

Design the message to be localized

Modify the JavaScript code for the message

Create the language pack

Apply the language pack to your application

Verify the translation results

Design the message to be localized

Following the example, you create a field value pyCaption warning msg for the message text that you want to localize in the Pega Survey.

  1. Create a field value to store the message you want to localize, for example, pyCaption warning msg.
    Specify the values for the following fields:

    Field Name: pyCaption
    Field Value: warning_msg
    Description: warning_msg
    Localized Label: Specify any warning message that you want to display, for example:
    Are you sure you want to exit this page? If you leave the page now, the survey will be locked for 120 minutes.

    Field Value pyCaption warning_msg
    Field Value pyCaption warning_msg with Localized Label ​
  2. Create a single-value text property that maps to the field value created in Step 1.
    Single-value property pxTextInput
    Single-value property pxTextInput for Field Value pyCaption ​
  3. Insert a label into the section of the survey that points to the property whose value is handled by the JavaScript code to display the localized message.
    For example, here is a section that application users view.
    Section label for warning message
    Section label for the warning message
    1. Drag a layout of type free form 1 X 1.
    2. Insert a label in that cell.
    3. Configure the cell properties as follows:
      Value: warning_msg
      Label For: .warning_msg
      Inline Style: display:none; (This value hides the cell; it does not occupy space.)
      Cell properties for warning message
      Cell properties for warning message

Modify the JavaScript code for the message

Modify the JavaScript code used in the survey section harness to show the warning that you want users to see when they try to close the survey.

Follow this example, adapting it to meet your needs:

var warn_msg ="";//Empty the warning message variable

/*Add a listener function to fetch the warning message from the html*/

if(window.attachEvent)//For Internet Explorer 8 and earlier

window.attachEvent('onload', initPage);

else

window addEventListener(‘onload’, initPage);//For Internet Explorer 9 and later and Chrome and FireFox

/* The function below will fetch the localized value from the warning_msg label that you added to the section of the survey */

function initPage()

 

var labels = document.getElementsByTagName("label");

for(var i=0;i< labels.length;i++)

 

if(labels[i].htmlFor=="warning_msg")

warn_msg = labels[i].innerText;

break;// break from the loop when the message is found

 

 

/* Add another event listener to the Submit button to clear the warning message so that it is not displayed if the user actually submits the form and does not close it without completing it. You want to show the warning only if the user has not completed the survey */

document.getElementById("submitButton").onmouseup=clearMsg;

/*Attach the listener to the window so that it displays a warning message when it is being closed.

window.onbeforeunload=showWarning;

 

//Method to clear the message so that warning message is not displayed on Submit

function clearMsg()

 

warn_msg="";

 

//Method to show the localized warning message

function showWarning()

 

if(warn_msg!="")

return warn_msg;

 

Create the language pack

Using the Localize Application wizard, you import the language ruleset (German, in this example) and follow the remaining steps to create the language pack. When you are done, you have a .zip file of the language translation for use in your application.

  1. From the User Interface landing page, click Tools > Translate to New Language to open the Localize Application wizard.
    User Interface Tools Translate to New Language
    User Interface landing page > Tools > Translate to New Language
  2. In the Localize Application wizard, select the application ruleset and version.
    Localize Application wizard Select Application Rulesets
    Localize Application wizard, Step 1, Select Application Rule Sets ​
  3. Wait for the system to verify that localization is enabled for all user interface components of your application.
    Localize Application wizard Verify Localization Is On
    Localize Application wizard, Step 2, Verify Localization Is On ​
  4. Optionally, perform manual tasks outside of the wizard to update the rules, properties, and portals as needed.
    Localize Application wizard Manual Tasks
    Localize Application wizard, Step 3, Manual Tasks ​
  5. Select the language that you want for localization, for example, German.​
    Localize Application wizard Select Languages
    Localize Application wizard, Step 4, Select Languages
  6. Check for the language pack, selecting the option that applies to your application:
    Acquired the Pegasystems language pack
    Add all PRPC field values to my application translation pack
    Already translated the PRPC field values or not using out-of-box components
    In this example, the first option is selected: Acquired the Pegasystems language pack.

    Localize Application wizard Check for Language Pack
    Localize Application wizard, Step 5, Check for Language Pack
  7. Set the options for handling an existing translation of the field and providing sample files and base field values from any rulesets.

    Localize Application wizard Set Options
    Localize Application wizard, Step 6, Set Options
  8. Export the translation by clicking the language to create the translation pack .zip file.

    Localize Application wizard Export Translations
    Localize Application wizard, Step 7, Export Translations
  9. When prompted, save the translation pack .zip file to a local folder.

    Download message prompting to open or save the .ZIP file
    Prompt to open or save the language pack .zip file
  10. Close the Localize Application wizard.

Apply the language pack to your application

In the downloaded language pack, you work with the TextToTranslate.xml file to apply the localized message to your application. Then you return to the Localize Application wizard to work with the translation that is in progress. You import the translated language ruleset, upload the language pack, and view the results of the translation.

  1. Extract the downloaded language pack and open the TextToTranslate.xml file to see the English language label.
    1. Browse the folder to find the TextToTranslate.xml file.
      Downloaded language pack TranslationFiles lists TextToTranslate.xml
      Downloaded language pack TranslationFiles lists the TextToTranslate.xml file
    2. Open the TextToTranslate.xml file and find the localized English label.
      Remember to open the TextToTranslate.xml file in Microsoft Excel because this is the format that is required for modifying and delivering the language pack.

  2. In the Translation column, enter the Translated Warning message. Save and close the file.

    Translation column for translated text
    Translation column holds translated warning message
  3. Archive the folder again: Create a .zip file again of the extracted folder.

  4. In PRPC, from the User Interface landing page, click Tools > List translations in progress.

    User Interface landing page, Tools, List Translations in Progress
    User Interface landing page, Tools, List Translations in Progress
  5. Select the language, for example, German.

    Wizards in progress German
    Wizards In progress, Open, Import German translations
  6. In the Localize Application wizard, Select Import Rule Sets, specify the German language ruleset and version.

    Important Make sure that the language ruleset version matches the base ruleset version. If the language ruleset does not match the base ruleset, the Field Value rule is not selected for translation.

    Localize Application wizard Select Import Rule Sets
    Localize Application wizard, Step 1, Select Import Rule Sets
  7. Upload the translation pack .zip file that contains the German translations by browsing and selecting the file.

    Localize Application wizard Upload Translation Pack
    Localize Application wizard, Step 2, Upload Translation Pack
  8. See the confirmation message: File uploaded successfully.

    Localize Application wizard File uploaded successfully
    Localize Application wizard, Step 2, Successful upload of translation pack
  9. Click Next to complete the Localize Application wizard.

    Localize Application wizard finished
    Localize Application wizard confirmation of completion

Verify the translation results

You verify the translation results by changing the Locale Settings in your application.

  1. Change the browser locale setting to German to see the warning message in German.
    1. From the User Interface landing page, click Tools > Locale Settings.
      User Interface landing page, Tools, Locale Settings
      User Interface landing page, Tools, Locale Settings
    2. In Locale Settings, the Use Locale field, select Deutsch.
      Locale Settings, Use Locale, Deutsch
      Locale Settings, Use Locale Deutsch
  2. Run the flow to see the warning message in context when you close the survey.
    Run flow to test message translated to German
    Warning message translated to German
    In this example, the browser locale is set to English and the PRPC application locale is set to German. The text of the Windows security dialog box remains in English, which is the locale set by the browser for this test case. The text of the warning message, however, displays the German translation of the English text for the PRPC application. When you and other users click the link directly in the application, you can see the entire message displayed in the language set for your locale in your browser.
  3. Repeat Steps 1 and 2 to test the translated warning message in another locale, for example, English or Hindi.
    Test English locale setting
    Test English locale setting
    Test Japanese locale setting
    Test Hindi locale setting

Published May 5, 2015 — Updated February 11, 2016

Related Content

Have a question? Get answers now.

Visit the Pega Support Community to ask questions, engage in discussions, and help others.