-
Notifications
You must be signed in to change notification settings - Fork 1
translit
Moe Myat Zaw edited this page Jun 7, 2019
·
1 revision
The translit method is a main method to convert source text to targeted text using transliteration rules.
translit(
sourceText: string,
ruleName?: string,
rulesToUse?: TranslitRule | TranslitRulePhase[] | TranslitRuleItem[],
userOptions?: { [option: string]: boolean | string },
trace?: boolean): Observable<TranslitResult>-
sourceText- Input string to convert. -
ruleName- The rule name to load and cache rule. -
rulesToUse- One-time transliterate rules to use. -
userOptions- The options user selected to check with 'when' rule options. -
trace- Flag to include conversion trace information in the result.
Returns the Observable<TranslitResult> object if there is no validtion or parsing error.
/**
* The transliteration result interface.
*/
export interface TranslitResult {
/**
* The converted output text.
*/
outputText: string;
/**
* The value will be 'true' if source text is converted or replaced.
*/
replaced?: boolean;
/**
* Conversion duration in miliseconds.
*/
duration?: number;
/**
* Conversion information for debugging.
*/
traces?: TranslitTraceInfo[];
} /**
* Conversion trace information.
*/
export interface TranslitTraceInfo {
/**
* The description of applied rule item information.
*/
description: string;
/**
* The 'from' text of rule item.
*/
from: string;
/**
* The 'to' text of rule item.
*/
to?: string;
/**
* The matched string.
*/
matchedText: string;
/**
* The previous string.
*/
previousText: string;
/**
* The replaced string.
*/
replacedText: string;
}Throws either TranslitParseError or Error instance if there is any parsing error or validation error.