skip to main content
Corticon Server: Integration & Deployment Guide : Enabling Server handling of locales, languages, and timezones : Examples of cross-locale processing
 

Try Corticon Now

Examples of cross-locale processing

The following examples use the installed Progress Application Server and the API test scripts. It also presents a sample of the OrderProcessing sample Rulesheet enhanced to show localization to German rule statements and some test conditions and actions that expose the features of cross-locale processing.
The internationalization feature uses the English rule statements in replies to requests. When the Server is set to German, it uses the German rule statements in replies to requests.
When a request does not indicate its language and locale, and the request has decimal values or literal dates that are not consistent with the server's format, the request message throws an exception.

<ns1:Messages version="1.10">
<ns1:Message>
<ns1:severity>Violation</ns1:severity>
<ns1:text>An unexpected error occurred in Input Data:
java.lang.NumberFormatException</ns1:text>
</ns1:Message>
</ns1:Messages>
Note: If the request has no decimal values or literal dates, the response contains rule statements in the server's locale.
When a request includes the execution property PROPERTY_EXECUTION_LOCALE and a valid value, the provided locale is used to parse data values in the request document and to produce the response document. In the response document, the provided locale is used to format data values and to select the localized rule messages to return. Data types with locale dependencies are decimal and literal dates. If an invalid locale is provided, an exception is thrown. If localized rule messages were not defined, the default rule messages are used.
Using the example of the English-German rulesheet, and assuming that the Decision Service is running on a en-US system, consider the following messages:
The following request specifies German, de-DE, as its locale:

<CorticonRequest xmlns="urn:Corticon" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" decisionServiceName="Order_localeAware">
<ExecutionProperties>
<ExecutionProperty name="PROPERTY_EXECUTION_LOCALE" value="de-DE" />
</ExecutionProperties>
<WorkDocuments>
<Order id="Order_id_1">
<dueDate>08/25/14</dueDate>
<total xsi:nil="1" />
<myItems id="Item_id_1">
<price>10,250000</price>
<product>Ball</product>
<quantity>20</quantity>
</myItems>
</Order>
<Order id="Order_id_2">
<dueDate>07/27/14</dueDate>
<myItems id="Item_id_4">
<price>0,050000</price>
<product>Pencil</product>
<quantity>100</quantity>
</myItems>
</Order>
</WorkDocuments>
</CorticonRequest>
The response specifies German, de-DE, as its locale. The messages are in German and the decimal values are delimited correctly:

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<ns1:CorticonResponse xmlns:ns1="urn:Corticon"
xmlns="urn:Corticon" decisionServiceName="Order_localeAware">
<ns1:ExecutionProperties>
<ns1:ExecutionProperty name="PROPERTY_EXECUTION_LOCALE"
value="de-DE" />
</ns1:ExecutionProperties>
<ns1:WorkDocuments>
<ns1:Order id="Order_id_1">
<ns1:dueDate>2014-09-25</ns1:dueDate>
<ns1:shipped>true</ns1:shipped>
<ns1:shippedOn>2014-04-30T23:00:00.000-05:00</ns1:shippedOn>
<ns1:total>205,000000</ns1:total>
<ns1:myItems id="Item_id_1">
<ns1:price>10,250000</ns1:price>
<ns1:product>Ball</ns1:product>
<ns1:quantity>20</ns1:quantity>
<ns1:subtotal>205,000000</ns1:subtotal>
</ns1:myItems>
</ns1:Order>
<ns1:Order id="Order_id_2">
<ns1:dueDate>2014-08-27</ns1:dueDate>
<ns1:shipped>true</ns1:shipped>
<ns1:shippedOn>2014-04-30T23:00:00.000-05:00</ns1:shippedOn>
<ns1:total>5,000000</ns1:total>
<ns1:myItems id="Item_id_4">
<ns1:price>0,050000</ns1:price>
<ns1:product>Pencil</ns1:product>
<ns1:quantity>100</ns1:quantity>
<ns1:subtotal>5,000000</ns1:subtotal>
</ns1:myItems>
</ns1:Order>
</ns1:WorkDocuments>
<ns1:Messages version="1.10">
<ns1:Message>
<ns1:severity>Info</ns1:severity>
<ns1:text>die Zwischensumme der Posten für Pencil ist 5,000000.</ns1:text>
<ns1:entityReference href="#Item_id_4" />
</ns1:Message>
<ns1:Message>
<ns1:severity>Info</ns1:severity>
<ns1:text>die Zwischensumme der Posten für Ball ist 205,000000.</ns1:text>
<ns1:entityReference href="#Item_id_1" />
</ns1:Message>
<ns1:Message>
<ns1:severity>Info</ns1:severity>
<ns1:text>die Gesamt für die Bestellung 5,000000</ns1:text>
<ns1:entityReference href="#Order_id_2" />
</ns1:Message>
<ns1:Message>
<ns1:severity>Info</ns1:severity>
<ns1:text>die Gesamt für die Bestellung 205,000000</ns1:text>
<ns1:entityReference href="#Order_id_1" />
</ns1:Message>
<ns1:Message>
<ns1:severity>Info</ns1:severity>
<ns1:text>die Gesamt Paket versenden 05/01/14 12:00:00 AM</ns1:text>
<ns1:entityReference href="#Order_id_2" />
</ns1:Message>
<ns1:Message>
<ns1:severity>Info</ns1:severity>
<ns1:text>die Gesamt Paket versenden 05/01/14 12:00:00 AM</ns1:text>
<ns1:entityReference href="#Order_id_1" />
</ns1:Message>
</ns1:Messages>
</ns1:CorticonResponse>
</soapenv:Body>
</soapenv:Envelope>
This request specifies French, fr-FR, as its locale:

<ns1:CorticonResponse xmlns:ns1="urn:Corticon" xmlns="urn:Corticon" decisionServiceName="Order_localeAware">
<ns1:ExecutionProperties>
<ns1:ExecutionProperty name="PROPERTY_EXECUTION_LOCALE"
value="fr-FR" />
</ns1:ExecutionProperties>
...
The response specifies French as its locale but, while the messages default to English, the decimal values are processed and then delimited correctly:

<ns1:Messages version="1.10">
<ns1:Message>
<ns1:severity>Info</ns1:severity>
<ns1:text>The subtotal of line item for Ball is 205,000000.</ns1:text>
<ns1:entityReference href="#Item_id_1" />
</ns1:Message>
<ns1:Message>
<ns1:severity>Info</ns1:severity>
<ns1:text>The subtotal of line item for Pencil is 5,000000.</ns1:text>
<ns1:entityReference href="#Item_id_4" />
</ns1:Message>
...