pp108 : localization_makeCompositeText()

localization_makeCompositeText()

 

This is a default method available for all XForms. It enables you to translate strings that contain insertions to the language in which the XForm is currently being displayed.

Syntax

Script

localization_makeCompositeText(<TranslatableText>, insertion1,insertion2)

Parameters

Parameter

Description

TranslatableText

TranslatableText object that denotes the message to be translated.

insertion1

String or TranslatableText object.

  • If it is a String, it will be directly replaced as an insertion.
  • If it is a TranslatableText object, it will replace the translated value of the insertion.

Return Value

Returns a TranslatableText object that provides the translated string with insertions at the runtime.

Remarks

Process Platform XForms supports the translation feature that enables the internationalization of XForms. Using this feature, you can translate and view the labels on an XForm in any desired language. You can specify the various languages to be used and translate the labels in those languages. These definitions or translations are stored in a translation file with a .mlm (Multi Language Mapper) extension.

When the localization_makeCompositeText() method is executed, it searches for the dictionary of the XForm, identifies the string using the specified textidentifier, and retrieves the translation of the string.

Process Platform provides a translation service for each XForm, using which you can set the equivalent translation of each label. Use the Messages tab to add required translation strings for messages such as alerts, prompts, and notifications that may be displayed in the XForm at the runtime.

NOTE: You can achieve internationalization of an XForm by specifying the language code in its URL when opening it. Consider the below sample URL that defines the language code 'nl-NL' :

<url>/test/test1/languagepage.caf?language=nl-NL</url>

Examples

The localization_makeCompositeText() method supports the use of insertions in the message notifications. An insertion can be a TranslatableText object or a String. You must provide the text and insertion values of a message programmatically. The insertions are provided as arguments of the localization_makeCompositeText method. While translating messages with insertions, you must provide separate translations for the insertion values and the message text.

The following code demonstrates the use of string array to provide custom messages:

function Form_InitDone(eventObject) { 
//capital_of_county is the text identifier for the message 
The capital of {0} is {1} application.notify(localization_makeCompositeText(localization_get("capital_of_county"),"India","New Delhi")); 
//returns the message De hoofdstad van India is New Delhi in Dutch 
 
application.notify(localization_makeCompositeText(localization_get("capital_of_county"),"India" ,localization_get("New Delhi"))); //returns the message De hoofdstad van India is Nieuw Delhi in Dutch }

Related Topics

localization_get

localization_translateXML