Documentation

BX.translit

void|string
BX.translit(
 String str,
 Object params
);

The function performs transliteration of a string.

Function parameters

Parameter Description
str
params Possible keys for 'params' object:
  • max_len - maximum length of resulting string;
  • change_case - to which case the string must be converted: L – to lower case, U – to upper case, false – case should not change;
  • replace_space - string, for which space characters are replaced;
  • replace_other - string, for which the rest of non alpha-numeric characters are replaced;
  • delete_repeat_replace - flag that specifies whether to delete repeating replacements of non alpha-numeric characters;
  • use_google - defines whether an external service for translation of string is used before transliteration. By default, false.

    Parameter received this name due to the previous use of Google.Translate service. Because this service is not available, Yandex.Translation service is now used instead. Name of the parameter remained the same to preserve compatibility.

Additionaly, callback parameter can be specified, to which the result of the processing will be passed. If the 'use_google' parameter is specified as true, callback parameter is required.

Returned value

The function returns a transliterated string (or returns nothing, if the transliteration was deferred by the use_google parameter.)



© «Bitrix24», 2001-2024
Up