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.

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

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: pyCaptionField Value: warning_msgDescription: warning_msgLocalized 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 with Localized Label ​

Create a single-value text property that maps to the field value created in Step 1.Single-value property pxTextInput for Field Value pyCaption ​

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 the warning 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

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.

Check for the language pack, selecting the option that applies to your application:Acquired the Pegasystems language packAdd all PRPC field values to my application translation packAlready 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, Step 5, Check for Language Pack

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, Step 6, Set Options

Export the translation by clicking the language to create the translation pack .zip file.

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.

Extract the downloaded language pack and open the TextToTranslate.xml file to see the English language label.

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.

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

Translation column holds translated warning message

Archive the folder again: Create a .zip file again of the extracted folder.

In Locale Settings, the Use Locale field, select Deutsch.Locale Settings, Use Locale Deutsch

Run the flow to see the warning message in context when you close the survey.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.

Repeat Steps 1 and 2 to test the translated warning message in another locale, for example, English or Hindi.
​ Test English locale settingTest Hindi locale setting

Related Content

Have a question? Get answers now.

About Pegasystems

Pegasystems is the leader in cloud software for customer engagement and operational excellence. If you’ve driven a car, used a credit card, called a company for service, opened an account, flown on a plane, submitted a claim, or performed countless other everyday tasks, chances are you’ve interacted with Pega. For the past 30 years, our technology – CRM, digital process automation, robotics, AI, and more – has empowered the world’s leading companies to achieve breakthrough results.