This namespace is used for text and message localization related functions of Oracle Application Express.
Add messages for use by apex.lang.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 attribute Used in JavaScript set to on.
Parameters:
Name | Type | Description |
---|---|---|
pMessages |
Object | An object whose properties are message keys (names), and the values are localized message text. |
Example
apex.lang.addMessages( {
APPLY_BUTTON_LABEL: "Apply"
} );
Remove all messages. This method is rarely needed. Many Oracle Application Express components rely on client-side messages, so if you clear the messages you need to add any needed messages again.
Example
apex.lang.clearMessages();
Formats a message. Same as apex.lang.formatMessage except the message pattern is given directly. It is already localized or isn't supposed to be. It is not a key. The replacement arguments are HTML escaped.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
pPattern |
string | The message pattern. | |
pValues |
* |
<repeatable> |
Any number of replacement values, one for each message parameter %0 to %9. Non string arguments are converted to strings. |
Returns:
- Type
- string
Example
apex.lang.format( "Total cost: $%0", orderTotal );
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:
Name | Type | Attributes | Description |
---|---|---|---|
pKey |
string | The message key. The key is used to lookup the localized message text as if with getMessage. | |
pValues |
* |
<repeatable> |
Any number of replacement values, one for each message parameter %0 to %9. Non string arguments are converted to strings. |
Returns:
- Type
- string
Example
apex.lang.formatMessage( "PROCESS_STATUS", progress );
Same as apex.lang.formatMessage except the replacement arguments are not HTML escaped. They must be known to be safe or will be used in a context that is safe.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
pKey |
string | The message key. The key is used to lookup the localized message text as if with getMessage. | |
pValues |
* |
<repeatable> |
Any number of replacement values, one for each message parameter %0 to %9. Non string arguments are converted to strings. |
Returns:
- Type
- string
Example
apex.lang.formatMessageNoEscape( "CONFIRM", inputValue );
Same as apex.lang.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:
Name | Type | Attributes | Description |
---|---|---|---|
pPattern |
string | The message pattern. | |
pValues |
* |
<repeatable> |
Any number of replacement values, one for each message parameter %0 to %9. Non string arguments are converted to strings. |
Returns:
- Type
- string
Example
apex.lang.formatNoEscape( "You entered %0", inputValue );
Return the message associated with the given key. The key is looked up in the messages added with the apex.lang.addMessages, apex.lang.loadMessages, or apex.lang.loadMessagesIfNeeded functions.
Parameters:
Name | Type | Description |
---|---|---|
pKey |
string | The message key. |
Returns:
- Type
- string
Example
apex.lang.getMessage( "OK_BTN_LABEL" );
Return true if pKey exists in the messages added with the apex.lang.addMessages, apex.lang.loadMessages, or apex.lang.loadMessagesIfNeeded functions.
Parameters:
Name | Type | Description |
---|---|---|
pKey |
string | The message key. |
Returns:
- Type
- boolean
Example
if ( apex.lang.hasMessage( "EXTRA_MESSAGE" ) ) {
text += apex.lang.getMessage( "EXTRA_MESSAGE" );
}
Load additional messages from the server.
When an APEX page loads it automatically loads any text messages that have attribute Used in JavaScript set to on. This function is useful when there are strings that are not always needed on the client but can be loaded on demand.
Parameters:
Name | Type | Description |
---|---|---|
pMessageKeys |
Array.<string> | An array of message keys (names) to load. |
Returns:
- Type
- Promise
Example
var promise = apex.lang.loadMessages( ["MY_MESSAGE1", "MY_MESSAGE2"] );
promise.done(function() {
var text = apex.lang.getMessage("MY_MESSAGE1");
// use text somehow
}.fail(function() {
apex.debug.error( "Could not get messages." );
};
Load additional messages from the server only if they are not already loaded.
When an APEX page loads it automatically loads any text messages that have attribute Used in JavaScript set to on. This function is useful when there are strings that are not always needed on the client but can be loaded on demand.
Parameters:
Name | Type | Description |
---|---|---|
pMessageKeys |
Array.<string> | An array of message keys (names) that are needed by pCallback. These messages will be loaded if needed. |
pCallback |
A no argument function that is called when all the keys have been loaded. If all the messages have already been loaded then this function is called right away. |
Example
apex.lang.loadMessage( ["DETAILED_HELP_INFO"], function() {
apex.message.alert( apex.lang.getMessage( "DETAILED_HELP_INFO" );
} );