Skip to main content

$nlp.fixKeyboardLayout

The method corrects the text by changing the layout from Latin to Cyrillic.

Syntax

$nlp.fixKeyboardLayout("Ghbdtn!"); // => "Привет!"

The method accepts a string and returns it in Cyrillic layout. For example, for Ghbdtn! the method returns Привет!.

caution
  • If there are Cyrillic characters in the string, the method returns null.

  • If you pass to the method an object instead of a string, the function returns хщиоусе Щиоусеъ, because it changes the layout of the line [object Object].

How to use

Use it in combination with $nlp.match:

theme: /

state: Hello
intent!: /hello
a: match

state: CatchAll
event!: noMatch
script:
var text = $parseTree.text;
$temp.fixedText = $nlp.fixKeyboardLayout(text);
# Call $nlp.match if we got the fixed string
if: $temp.fixedText
script:
var matchResults = $nlp.match($temp.fixedText, "/");
// If we found a state, transition to it
if (matchResults){
$parseTree = matchResults.parseTree;
var nextState = matchResults.targetState;
$reactions.transition(nextState);
};
a: I do not understand