You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 12 Current »

This class provides methods returning translated messages. This class has no constructor; methods can be accessed using the s_i18n global object.

getMessage(msgKey, callback)


This method returns a string containing a message in a user language for a specified string. If this string does not have localization for the current language, or it does not exist at all, the method returns the msgKey value.

The msgKey parameter should pass the string for translation, and the callback parameter is the function that will be executed after the server response.

Please note that this method is asynchronous; for better performing, use the await keyword like shown in the code example below.


Parameter(s):

NameTypeMandatoryDefault Value
msgKeyStringYN
callbackfunctionYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

if (!s_form.getValue('condition') && !s_form.getValue('script')) {
  await s_i18n.getMessage('Specify conditions in "Condition" [condition] or "Script" [script] fields.', (response) => {
    s_form.addErrorMessage(response);
  });
  return false;
}

getMessages(msgKeys, callback)


This method returns an array of strings that contains messages in a user language. If these strings do not have localization for the current language, or they do not exist at all, the method returns msgKey string values.

The msgKeys parameter should pass the array of strings for translation, and the callback parameter is the function that will be executed after the server response.

Please note that this method is asynchronous; for better performing, use the await keyword like shown in the code example below.


Parameter(s):

NameTypeMandatoryDefault Value
msgKeysArray of stringsYN
callbackfunctionYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

const data = {};
const btnTitles = ['Accept', 'Cancel'];
await s_i18n.getMessages(btnTitles, (response) => {
  [data.acceptBtnTitle, data.cancelBtnTitle] = response;
});

  • No labels