31.6 apex.lang namespace

This namespace is used for localization related functions of Oracle Application Express.

31.6.1 apex.lang.addMessages

Add messages for use by getMessage and the format functions. Can be called multiple times. Additional messages are merged. It is generally not necessary to call this function, because it is automatically called with all the application text messages that have Used in JavaScript set to Yes.

Parameters

Table 31-21 Parameters for apex.lang.addMessages

Name Type Description

pMessages

Object

An object whose properties are message keys and the values are localized message text.

Example

This example adds a message.

apex.lang.addMessages({
  APPLY_BUTTON_LABEL: "Apply"
});

31.6.2 apex.lang.clearMessages

Remove all messages.

Parameters

None.

Example

This example removes all messages.

apex.lang.clearMessages()

31.6.3 apex.lang.format

Same as formatMessage except the message pattern is given directly (already localized or isn't supposed to be). It is not a key. The replacement arguments are HTML escaped.

Parameters

Table 31-22 Parameters for apex.lang.format

Name Type Description

pPattern

String

The message pattern that contains one or more parameters %0 to %9.

...*

any

Optional replacement values one for each message parameter %0 to %9. Non string arguments are converted to strings.

Returns

The localized and formatted message text string.

Example

This example returns Total cost: $34.00 assuming the orderTotal variable equals 34.00.

apex.lang.format("Total cost: $%0", orderTotal);

31.6.4 apex.lang.formatMessage

Format a message. Parameters in the message %0 to %9 are replaced with the corresponding function argument. Use %% to include a single %. The replacement arguments are HTML escaped.

Parameters

Table 31-23 Parameters for apex.lang.formatMessage

Name Type Description

pKey

String

The key is used to lookup the localized message text as if with getMessage.

...*

any

Optional replacement values one for each message parameter %0 to %9. Non string arguments are converted to strings.

Returns

The localized and formatted message text string. If the key is not found then the key is returned.

Example

This example returns "Process 60% complete" when the PROCESS_STATUS message text is "Process %0%% complete" and the progress variable value is 60.

apex.lang.formatMessage("PROCESS_STATUS", progress);

31.6.5 apex.lang.formatMessageNoEscape

Same as formatMessage except the replacement arguments are not HTML escaped. They must be known to be safe or are used in a context that is safe. See "apex.lang.formatMessage".

Parameters

Table 31-24 Parameters for apex.lang.formatMessageNoEscape

Name Type Description

pKey

String

The key is used to lookup the localized message text as if with getMessage.

...*

any

Optional replacement values one for each message parameter %0 to %9.

Returns

The localized and formatted message text string. If the key is not found then the key is returned.

Example

This example returns "You entered <ok>" when the CONFIRM message text is "You entered %0" and the inputValue variable value is "<ok>". Note this string must be used in a context where HTML escaping is done to avoid XSS vulnerabilities.

apex.lang.formatMessageNoEscape("CONFIRM", inputValue);

31.6.6 apex.lang.formatNoEscape

Same as format, except the replacement arguments are not HTML escaped. They must be known to be safe or are used in a context that is safe.

Parameters

Table 31-25 Parameters for apex.lang.formatNoEscape

Name Type Description

pPattern

String

The message pattern that contains one or more parameters %0 to %9.

...*

any

Optional replacement values one for each message parameter %0 to %9.

Returns

The localized and formatted message text string. If the key is not found then the key is returned.

Example

This example returns "You entered <ok>" when the inputValue variable value is "<ok>". Note this string must be used in a context where HTML escaping is done to avoid XSS vulnerabilities.

apex.lang.formatNoEscape("You entered %0", inputValue);

See Also:

"apex.lang.format"

31.6.7 apex.lang.getMessage

Return the message associated with the given key. The key is looked up in the messages added with addMessages.

Parameters

Table 31-26 Parameters for apex.lang.getMessage

Name Type Description

pKey

String

The message key.

Returns

The localized message text string. If the key is not found then the key is returned.

Example

This example returns "OK" when the localized text for key OK_BTN_LABEL is "OK".

apex.lang.getMessage("OK_BTN_LABEL");