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

Compare with Current View Page History

« Previous Version 11 Next »

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 English version.

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

This method will get only the message that has the Category attribute equal to 'app'.


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')) {
  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 the English versions.

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.

This method will get only the messages that have the Category attribute equal to 'app'.


Parameter(s):

NameTypeMandatoryDefault Value
msgKeysArrayYN
callbackfunctionYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

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

  • No labels