LogoPixi’VN
indexFunctions

~~Function: onReplaceTextAfterTranslation()~~

> onReplaceTextAfterTranslation(getTextToReplace): void

Defined in: src/functions/replace.ts:30

Parameters

getTextToReplace

(key) => string | undefined

The function to get the text to replace

Returns

void

Deprecated

Use TextReplaces instead.

This function is called after the onInkTranslate function is called. It will replace the text between square brackets. It can be used for example to replace the character id with the character name: If there are a character with a name "John" and id "john", and the text is "Hello, my name is [john]", the following function will return "Hello, my name is John"

Example

import { onReplaceTextAfterTranslation } from 'pixi-vn-ink'
import { getCharacterById } from "@drincs/pixi-vn";

onReplaceTextAfterTranslation((key) => {
    let character = getCharacterById(key)
    if (character) {
        return character.name
    }

    // if return undefined, the system will not replace the character id
    return undefined
})