Types
JsxChildren
Type definition for JSX content that can be translated and rendered
Overview
JsxChildren represents JSX content that includes text, elements, and variables for translation.
type JsxChildren = JsxChild | JsxChild[];Structure
type JsxChild = string | JsxElement | Variable;| Type | Description |
|---|---|
string | Plain text content |
JsxElement | Structured element |
Variable | Dynamic placeholder |
JsxElement
type JsxElement = {
t?: string; // tag name
i?: number; // id
d?: GTProp; // GT properties
c?: JsxChildren; // children
};Examples
Basic usage
import { JsxChildren, Variable } from 'generaltranslation';
// Simple text
const text: JsxChildren = "Welcome!";
// Text with variables
const greeting: JsxChildren = [
"Hello, ",
{ k: 'userName' } as Variable,
"!"
];Structured Elements
// Div element
const divElement: JsxChildren = {
t: 'div',
c: ['Content here']
};
// Link with title
const linkElement: JsxChildren = {
t: 'a',
d: { ti: 'Visit homepage' },
c: ['Click here']
};Related types
JsxChild- Individual child element typesJsxElement- Structured element definitions
How is this guide?