Types

JsxChildren

Type definition for JSX content that can be translated and rendered

Overview

JsxChildren represents JSX content containing text, elements, and variables for translation.

type JsxChildren = JsxChild | JsxChild[];

Structure

type JsxChild = string | JsxElement | Variable;
TypeDescription
stringPlain text content
JsxElementStructured element
VariableDynamic 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']
};

How is this guide?

JsxChildren