LogoPixi’VN
indexType aliases

Type Alias: ReplaceHandlerOptions

> ReplaceHandlerOptions = object

Defined in: src/handlers/interfaces/ReplaceHandler.ts:21

Configuration options for a text-replacement handler registered via TextReplaces.add.

Properties

description?

> optional description?: string

Defined in: src/handlers/interfaces/ReplaceHandler.ts:31

An optional human-readable description of what this handler does. Used for documentation purposes.


name

> name: string

Defined in: src/handlers/interfaces/ReplaceHandler.ts:26

A unique name that identifies this handler. Used for documentation and debugging purposes.


type?

> optional type?: "after-translation" | "before-translation"

Defined in: src/handlers/interfaces/ReplaceHandler.ts:64

When this handler should be invoked relative to the translation step.

  • "before-translation" – the handler runs before onInkTranslate is called. Useful for pre-processing tokens, e.g. converting [key] into {{key}} for i18next.
  • "after-translation" – the handler runs after onInkTranslate is called. Useful for substituting values that depend on the translated text.

Default

"before-translation"

validation

> validation: RegExp | "characterId" | "all" | ZodType<string>

Defined in: src/handlers/interfaces/ReplaceHandler.ts:53

Determines whether this handler should be invoked for a given [key] token.

  • "all" – the handler is always invoked for every token found.
  • "characterId" – the handler is invoked only when the key matches a registered character ID (i.e. the character is present in RegisteredCharacters).
  • RegExp – the key string is tested against the regular expression. The handler is invoked only if the regex matches.
  • ZodType<string> – the key string is validated with schema.safeParse(key). The handler is invoked only if validation succeeds.

Example

// RegExp: only replace keys that look like lowercase identifiers
validation: /^[a-z_]+$/

// Zod: only replace keys that are one of a fixed set of values
import { z } from "zod"
validation: z.enum(["player", "npc", "enemy"])